Re: [PATCH] tpm: adapt sysfs cancel path for new TPM driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/17/2015 09:24 AM, Daniel P. Berrange wrote:
On Tue, Nov 17, 2015 at 09:18:29AM -0500, Stefan Berger wrote:

To get that path right we need to test it's availability by opening it.
Unfortunately there's  problem with that now related to the test case below
where, if the test is run as non-root, /dev/null will be returned, and if
run as root possibly one of those constructed paths will be returned. What's
the best way to fix this ?
The unit tests should never depend on host state, so we should
not run this code at all.

You sould mock override the virTPMCreateCancelPath method entirely
I guess to return a fixed filename.

Great. Would you accept this code here in the mock?

+
+char *
+virTPMCreateCancelPath(const char *devpath)
+{
+    const char *dev = "/sys/class/misc/tpm0/device/cancel";
+    size_t len = strlen(dev);
+    char *path = malloc(len + 1);
+
+    (void)devpath;
+
+    if (path)
+        memcpy(path, dev, len + 1);
+
+    return path;
+}


   Stefan



Regards,
Daniel

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]