summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4de89c1)
Expand the '#ifdef __linux__' block in src/compat-cpu.h to all static
inline functions related to sysfs since they are only useful on Linux
and fail to build on some non-Linux platforms. This issue was reported
on QNX.
The corresponding unit tests have to be skipped on non-Linux platforms.
Thanks to Elad Lahav <e2lahav@gmail.com> for reporting this issue.
Change-Id: I17c88a9a2fb5b9be6cf5325234a18ff40788cd09
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
/*
* Get the highest CPU id from sysfs.
*
/*
* Get the highest CPU id from sysfs.
*
/*
* On Linux try sysfs first and fallback to sysconf.
*/
/*
* On Linux try sysfs first and fallback to sysconf.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include "compat-smp.h"
int main(int argc, char *argv[])
#include "compat-smp.h"
int main(int argc, char *argv[])
else
return EXIT_FAILURE;
}
else
return EXIT_FAILURE;
}
+
+#else
+
+int main(void)
+{
+ return EXIT_SUCCESS;
+}
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include "compat-smp.h"
int main(int argc, char *argv[])
#include "compat-smp.h"
int main(int argc, char *argv[])
else
return EXIT_FAILURE;
}
else
return EXIT_FAILURE;
}
+
+#else
+
+int main(void)
+{
+ return EXIT_SUCCESS;
+}
+#endif
ok $? "test_get_cpu_mask_from_sysfs - with '\n' expected: '$cpumask', result: '$result'"
}
ok $? "test_get_cpu_mask_from_sysfs - with '\n' expected: '$cpumask', result: '$result'"
}
+if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then
+ plan_tests $NUM_TESTS
-test_test_get_cpu_mask_from_sysfs ""
-test_test_get_cpu_mask_from_sysfs "0"
-test_test_get_cpu_mask_from_sysfs "0-3"
-test_test_get_cpu_mask_from_sysfs "0,3-7,9"
+ test_test_get_cpu_mask_from_sysfs ""
+ test_test_get_cpu_mask_from_sysfs "0"
+ test_test_get_cpu_mask_from_sysfs "0-3"
+ test_test_get_cpu_mask_from_sysfs "0,3-7,9"
+else
+ plan_skip_all "Linux specific tests."
+fi
ok $? "test_get_cpu_mask_from_sysfs_cxx - with '\n' expected: '$cpumask', result: '$result'"
}
ok $? "test_get_cpu_mask_from_sysfs_cxx - with '\n' expected: '$cpumask', result: '$result'"
}
+if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then
+ plan_tests $NUM_TESTS
-test_test_get_cpu_mask_from_sysfs_cxx ""
-test_test_get_cpu_mask_from_sysfs_cxx "0"
-test_test_get_cpu_mask_from_sysfs_cxx "0-3"
-test_test_get_cpu_mask_from_sysfs_cxx "0,3-7,9"
+ test_test_get_cpu_mask_from_sysfs_cxx ""
+ test_test_get_cpu_mask_from_sysfs_cxx "0"
+ test_test_get_cpu_mask_from_sysfs_cxx "0-3"
+ test_test_get_cpu_mask_from_sysfs_cxx "0,3-7,9"
+else
+ plan_skip_all "Linux specific tests."
+fi
struct parse_test_data {
const char *buf;
int expected;
struct parse_test_data {
const char *buf;
int expected;
+
+#else
+
+int main(void)
+{
+ plan_skip_all("Linux specific tests.");
+
+ return exit_status();
+}
+#endif
+if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then
+ plan_tests $NUM_TESTS
-diag "get_max_cpuid_from_sysfs"
+ diag "get_max_cpuid_from_sysfs"
-test_data=(0 "cpu0")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(0 "cpu0")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(1 "cpu0" "cpu1")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(1 "cpu0" "cpu1")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(1 "cpu1" "cpu0")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(1 "cpu1" "cpu0")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(3 "cpu3")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(3 "cpu3")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(99 "cpu99")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(99 "cpu99")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(3 "cpu0" "cpu3")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(3 "cpu0" "cpu3")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(0 "cpu" "cpu0")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(0 "cpu" "cpu0")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(5 "cpu" "cpu5")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(5 "cpu" "cpu5")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(-1 "toto")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(-1 "toto")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(-1 "cpu")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(-1 "cpu")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(-1 "cpua" "cpud")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(-1 "cpua" "cpud")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
-test_data=(-1 "cpufreq" "cpuidle")
-test_get_max_cpuid_from_sysfs "${test_data[@]}"
+ test_data=(-1 "cpufreq" "cpuidle")
+ test_get_max_cpuid_from_sysfs "${test_data[@]}"
+else
+ plan_skip_all "Linux specific tests."
+fi
+if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then
+ plan_tests $NUM_TESTS
-diag "get_max_cpuid_from_sysfs_cxx"
+ diag "get_max_cpuid_from_sysfs_cxx"
-test_data=(0 "cpu0")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(0 "cpu0")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(1 "cpu0" "cpu1")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(1 "cpu0" "cpu1")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(1 "cpu1" "cpu0")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(1 "cpu1" "cpu0")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(3 "cpu3")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(3 "cpu3")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(99 "cpu99")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(99 "cpu99")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(3 "cpu0" "cpu3")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(3 "cpu0" "cpu3")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(0 "cpu" "cpu0")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(0 "cpu" "cpu0")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(5 "cpu" "cpu5")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(5 "cpu" "cpu5")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(-1 "toto")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(-1 "toto")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(-1 "cpu")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(-1 "cpu")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(-1 "cpua" "cpud")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(-1 "cpua" "cpud")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
-test_data=(-1 "cpufreq" "cpuidle")
-test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+ test_data=(-1 "cpufreq" "cpuidle")
+ test_get_max_cpuid_from_sysfs_cxx "${test_data[@]}"
+else
+ plan_skip_all "Linux specific tests."
+fi
ret = get_possible_cpus_array_len();
ok(ret > 0, "get_possible_cpus_array_len (%d > 0)", ret);
ret = get_possible_cpus_array_len();
ok(ret > 0, "get_possible_cpus_array_len (%d > 0)", ret);
ret = get_num_possible_cpus_fallback();
ok(ret > 0, "get_num_possible_cpus_fallback (%d > 0)", ret);
ret = get_num_possible_cpus_fallback();
ok(ret > 0, "get_num_possible_cpus_fallback (%d > 0)", ret);
+#else
+ skip(1, "Linux specific test.");
+#endif