If access(some_file, W_OK) is executed by root it will return success even if the file has read-only permission. Use 'open' to test sysfs file for write permission.
Signed-off-by: Alexey Kodanev <[email protected]> --- .../kernel/device-drivers/acpi/ltp_acpi_cpufreq.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c b/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c index 175bf4c..f1d3d5a 100644 --- a/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c +++ b/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c @@ -31,6 +31,9 @@ #include <sched.h> #include <sys/time.h> #include <pthread.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #include "test.h" #include "usctest.h" @@ -69,12 +72,15 @@ static void cleanup(void) static void setup(void) { + int fd; tst_require_root(NULL); - if (access(boost, R_OK | W_OK)) { + fd = open(boost, O_RDWR); + if (fd == -1) { tst_brkm(TCONF, NULL, "acpi-cpufreq not loaded or overclock not supported"); } + close(fd); tst_sig(FORK, DEF_HANDLER, cleanup); -- 1.7.1 ------------------------------------------------------------------------------ Is your legacy SCM system holding you back? Join Perforce May 7 to find out: • 3 signs your SCM is hindering your productivity • Requirements for releasing software faster • Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
