1. 07 Dec, 2020 1 commit
    • Christian Kellner's avatar
      test/common: conditionally re-enable atime checks · c2f1d5c4
      Christian Kellner authored
      The checks for modifying the access time via bolt_fs_touch was
      previously disabled because it did not work on file-systems
      that have the noatime flag set (for very obvious reasons).
      Separate these checks out and re-enable them but make their
      execution depended on the file-system support for access times,
      as reported via statvfs(2).
      c2f1d5c4
  2. 06 Dec, 2020 1 commit
    • Robert Hensing's avatar
      test: Disable filesystem access time checks · e2962df4
      Robert Hensing authored
      Access time is not always supported, so support for it is best-effort.
      We disable such assertions so bolt can be unit tested on systems that have
      "noatime" configured to speed up the filesystem.
      e2962df4
  3. 01 Dec, 2020 8 commits
  4. 30 Nov, 2020 6 commits
    • Christian Kellner's avatar
      test/mock: plug another tiny leak · c687041c
      Christian Kellner authored
      When removing the host device via mock_sysfs_host_remove, destroy
      the MockDevice for the host.
      c687041c
    • Christian Kellner's avatar
      glue: fix memory leak in conv_flags_to_str · 0b97bcaa
      Christian Kellner authored
      The function 'bolt_flags_class_to_string' returns a dynamically
      allocated string. This was previously not freed, creating a memory
      leak. Its ownership is now correctly transferred to the GVariant
      instead.
      0b97bcaa
    • Christian Kellner's avatar
      glue: plug tiny memory leak by freeing custom_id · 27ae4440
      Christian Kellner authored
      The memory for custom_id, to identify a custom conversion, is
      dynamically allocated, but was not freed in bolt_wire_conv_unref.
      Explicitly set it to NULL in the other constructor so we don't
      attempt to free invalid memory.
      27ae4440
    • Christian Kellner's avatar
      guard: ensure guard->path is always freed · 6f7b323f
      Christian Kellner authored
      Normally 'path' gets freed in bolt_guard_remove, which is called
      from the dispose method of the BoltGuard. There is one exception
      though: when the pipe (named fifo) is still active, we do not
      unlink the path, since we want to recover that guard later. In
      that case the memory for path will be leaked. Add an additional
      g_clear_pointer for path in the 'finalize' method to ensure that
      path always gets freed.
      6f7b323f
    • Christian Kellner's avatar
      guard: add pre-condition check in guard_save · 48cdeb20
      Christian Kellner authored
      Ensure that we are not saved already in 'bolt_guard_save'.
      48cdeb20
    • Christian Kellner's avatar
      test: fix various small memory leaks · c4e35871
      Christian Kellner authored
      Add missing g_clear_pointer / g_clear_object calls when a pointer
      was re-used during the tests. In MockSysfs, free the force-power
      path. In test-glue, use g_autoptr for all allocated GParamSpecs.
      c4e35871
  5. 28 Nov, 2020 16 commits
    • Christian Kellner's avatar
      manager: plug tiny leak on finalize · 78fe16e3
      Christian Kellner authored
      Properly unref the config key file when finalizing the object.
      78fe16e3
    • Christian Kellner's avatar
      device: use host ident for host devices · 6a6968a7
      Christian Kellner authored
      If a device is a host device, i.e. does not have a parent device, use
      the new host identification method, which will transparently fall
      back to use the SMBIOS/DMI information, in case the standard
      device information is not available, which is the case on embedded
      thunderbolt controllers.
      6a6968a7
    • Christian Kellner's avatar
      test/sysfs: check host identification · 290143fb
      Christian Kellner authored
      Add a test to check all host identification method code paths,
      including the standard one via 'bolt_sysfs_device_ident' as
      well as the fallback to DMI information.
      290143fb
    • Christian Kellner's avatar
      test/mock: add the ability to mock the DMI id dev · 2dd16dbb
      Christian Kellner authored
      Add the ability to mock the SMBBIOS/DMI sysfs device. For now only
      the sys_vendor, product_{name, version} attributes are supported,
      which is what we us in bolt.
      2dd16dbb
    • Christian Kellner's avatar
      test/mock: remove force power in finalize · 4ab9f056
      Christian Kellner authored
      If the force power device has not yet been removed, do so in the
      'finalize' method of the MockSysfs object. Move the un-ref'ing of
      the umockdev TestBed down so it happens after the hash tables
      are destroyed.
      4ab9f056
    • Christian Kellner's avatar
      test/mock-sysfs: ability to remove the host · dfbcf877
      Christian Kellner authored
      Add a new method that allows to remove a host device, i.e. unplug
      the device and remove it from the associated domain.
      dfbcf877
    • Christian Kellner's avatar
      sysfs: method to perform host identification · de337834
      Christian Kellner authored
      Add a new method to do host identification, which will first check
      if the host device can be identified via the normal device ident
      method. This will fail in case of embedded thunderbolt controller,
      which do not have a DROM and have no device and vendor information
      and thus no corresponding sysfs attributes. In that case we fall
      back to using the SMBIOS/DMI information for the system to ident
      the host.
      de337834
    • Christian Kellner's avatar
      names: add dmi id sysfs path and attribute names · 0defa936
      Christian Kellner authored
      The SMBIOS/DMI information is exported to userspace via sysfs,
      which is convenient, because the information can thus be read
      conveniently and as a non-root user.
      Define constants for relevant information that can be used to
      identify the computer / host, like the product, vendor and the
      general path to the sysfs device providing that information.
      0defa936
    • Christian Kellner's avatar
      test/syfs: check the sysfs_device_ident method · 520ef841
      Christian Kellner authored
      Check the 'bolt_sysfs_device_ident' method and the newly added
      'BoltIdent' structs.
      520ef841
    • Christian Kellner's avatar
      device+sysfs: new device ident struct · 95ef1b8b
      Christian Kellner authored
      Introduce a new BoltIdent struct that holds the name and vendor
      information for a thunderbolt device together with a reference
      to the 'struct udev_device' that provides those information.
      This binds the lifetime of the char pointers directly to the
      struct where they are contained and thus prevent accidental
      bugs where the strings are used after the udev_device is not
      valid anymore (got un-referenced).
      Since the struct holds a reference, define a clear method for
      it and the corresponding auto-cleanup method.
      Use the new BoltIdent struct for 'bolt_device_ident'. Re-factor
      it to not use a loop anymore.
      
      The read_sysattr_name helper, use in 'bolt_device_ident' now
      uses the recently introduced sysattr value getter.
      95ef1b8b
    • Christian Kellner's avatar
      sysfs: new attribute getter with glib style errors · 1adb3d00
      Christian Kellner authored
      Add a new sysfs attribute getter that does error reporting via
      GErrors. This will be convenient in a lot of places where the
      error handling is duplicated. Use it in the existing unique_id
      helper.
      1adb3d00
    • Christian Kellner's avatar
      manager: relabel Dell Inc. → Dell · e3282a50
      Christian Kellner authored
      This is mostly in preparation for the host identification via DMI
      where 'Dell Inc.' is used, whereby the thunderbolt host controller
      usually identifies itself as "Dell". To stay consistent we relabel
      the dmi id one.
      e3282a50
    • Christian Kellner's avatar
      manager: don't de-duplicate host device names · 9094fa36
      Christian Kellner authored
      When labeling a device, we normally do a duplication check, and
      if we find more than once device with the same name, we append
      a number suffix. Let's not do that for host devices, since they
      are arguably represent the same thing, even if technically the
      are different controllers with their own unique id.
      9094fa36
    • Christian Kellner's avatar
      manager: only import hosts with stable uuids · fbde3fd0
      Christian Kellner authored
      We started auto-importing the host device in commit f9205d16, with
      the reason that in non-native enumeration mode, the host device
      will disappear and the generation information will thus not be
      available anymore. But on embedded thunderbolt controller, the
      host device has an unstable unique_id, which means that host device
      will have a different uuid on next boot and thus can not be matched
      with the previously stored one. Thus stale host devices would
      accumulate in the store. Luckily, on embedded thunderbolt, the host
      device does not have device/vendor sysfs attributes, which means
      that currently creating a BoltDevice for it will not work, which is
      a bug, that also prevents stale host devices for now. Once that bug
      will get fixed we were to get stale host records, unless we don't
      store those host devices. To do so we check if the domain of the
      host device is stored which is an indicator of the uuid stability,
      checked via the pci id of the native host interface. If the domain
      is stored we store the host and vice versa.
      fbde3fd0
    • Christian Kellner's avatar
      device: move device identification to sysfs · 09aa6c53
      Christian Kellner authored
      Move the device identification, i.e. name and vendor detection, to
      bolt-sysfs.c as 'bolt_sysfs_device_ident'. This uses the existing
      helper function to first check `${attr}_name` for vendor and name
      attributes and then fall back to plain `${attr}`.
      09aa6c53
    • Christian Kellner's avatar
      device: add domain getter · f653fee2
      Christian Kellner authored
      Add the missing getter for the domain associated with a device, or
      NULL if there is none, i.e. the device is offline.
      f653fee2
  6. 24 Nov, 2020 6 commits
  7. 20 Nov, 2020 2 commits
    • Christian Kellner's avatar
      manager+sysfs: wait for hosts instead of domains · 8be049a5
      Christian Kellner authored
      In the manager's initialization, we want to make sure that we have
      at least one domain controller online in order detect the security
      level. Additionally, now that stale domains are cleaned up on store
      upgrades, we also want to make sure that domain controllers are
      fully initialized and the corresponding BotlDomain is online, so
      that we don't accidentally clean up a non-stale domain. In order
      to do so, we wait for at least one host controller to be present,
      not just the plain domain. For this we enumerate all domains and
      for each domain we enumerate the thunderbolt udev device directly
      beneath it (should only be one).
      Rename and re-purpose the various `count_domains` functions.
      Adapt the test to add host devices to the corresponding domains.
      8be049a5
    • Christian Kellner's avatar
      manager: better logging for domain de-registration · f3395f9c
      Christian Kellner authored
      Use the LOG_DOM () macro and do not use `bolt_domain_get_id`
      which might return NULL for disconnected domains.
      f3395f9c