]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix prerequisite for memcheck/tests/linux/timerfd-syscall.
authorFlorian Krohm <florian@eich-krohm.de>
Sun, 31 Jul 2011 03:22:45 +0000 (03:22 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sun, 31 Jul 2011 03:22:45 +0000 (03:22 +0000)
The testcase was executed despite uname -r being 2.6.9-42.EL
Extend tests/os_test.c to take an optional 2nd argument
which is a minimum version number. Use os_test in the
prerequisite expression.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11954

memcheck/tests/linux/timerfd-syscall.vgtest
tests/os_test.c

index 75a3f71752f7d63f8a762a463e8829269e389292..117bb9e8a8dfd42d302fde244b60cb2826f7f616 100644 (file)
@@ -1,2 +1,2 @@
-prereq: [ "$(uname)" = "Linux" ] && awk 'END{exit("'$(uname -r)'" >= "2.6.25" ? 0 : 1)}' </dev/null
+prereq: ../../../tests/os_test linux 2.6.25
 prog: timerfd-syscall
index d13bd6043bae8be26555be55ec85ea5a400e0e1b..b755e30706b7bf61cb7b7aff99c9da1bd1b595ee 100644 (file)
@@ -7,7 +7,8 @@
 // supports, which depends on what was chosen at configure-time.
 //
 // We return:
-// - 0 if the machine matches the asked-for OS
+// - 0 if the machine matches the asked-for OS and satisfies a
+//     version requirement, if any
 // - 1 if it doesn't match but does match the name of another OS
 // - 2 if it doesn't match the name of any OS
 // - 3 if there was a usage error (it also prints an error message)
@@ -25,10 +26,38 @@ char* all_OSes[] = {
    NULL
 };
 
-static Bool go(char* OS)
+#if defined(VGO_linux)
+static Bool matches_version(char *min_version)
+{
+   int a1, a2, a3, g1, g2, g3;  // 'a' = actual;  'g' = given
+
+   if (min_version == NULL)  return True;  // no version specified
+
+   // get actual version number
+   FILE *fp = fopen("/proc/sys/kernel/osrelease", "r");
+   if (fp == NULL || fscanf(fp, "%d.%d.%d", &a1, &a2, &a3) != 3) return False;
+   fclose(fp);
+
+   // parse given version number
+   if (sscanf(min_version, "%d.%d.%d", &g1, &g2, &g3) != 3) return False;
+
+//   printf("actual %d %d %d\n", a1, a2,a3);
+//   printf("given  %d %d %d\n", g1, g2,g3);
+
+   if (a1 > g1) return True;
+   if (a1 < g1) return False;
+   if (a2 > g2) return True;
+   if (a2 < g2) return False;
+   if (a3 >= g3) return True;
+
+   return False;
+}
+#endif
+
+static Bool go(char* OS, char *min_version)
 { 
 #if defined(VGO_linux)
-   if ( 0 == strcmp( OS, "linux" ) ) return True;
+   if ( 0 == strcmp( OS, "linux" ) && matches_version( min_version )) return True;
 
 #elif defined(VGO_darwin)
    if ( 0 == strcmp( OS, "darwin" ) ) return True;
@@ -46,11 +75,11 @@ static Bool go(char* OS)
 int main(int argc, char **argv)
 {
    int i;
-   if ( argc != 2 ) {
-      fprintf( stderr, "usage: os_test <OS-type>\n" );
+   if ( argc < 2 ) {
+      fprintf( stderr, "usage: os_test <OS-type> [<min-version>]\n" );
       exit(3);             // Usage error.
    }
-   if (go( argv[1] )) {
+   if (go( argv[1], argv[2] )) {
       return 0;            // Matched.
    }
    for (i = 0; NULL != all_OSes[i]; i++) {