Nicholas Nethercote 4c23a0b3e9 tests/arch_test is currently being used for two purposes:
- by vg_regtest for determining if a directory name matches an architecture;
- by various .vgtest files for detecting x86/AMD64 features.

This commit splits it in two for the two different purposes, which makes
things clearer.

Specific changes

- Moved the x86/AMD64 feature detection stuff out of arch_test.c, and
  into the new x86_amd64_feature.c.  Updated the relevant .vgtest files for
  the change.

- In vg_regtest, now a prereq command must return 0 (prereq satisfied) or 1
  (prereq not satisfied).  Anything else makes vg_regtest abort.  This
  makes obvious any problems with prereq tests rather than just making the
  tests skip innocuously.  (We previously had exactly such a problem on the
  DARWIN branch;  the x86 feature detection tests caused segfaults so the
  tests were incorrectly skipped.  This change will catch any similar future
  problem.)

- Changed os_test from a script to a C program, matching cpu_test.

- Removed some unintentional darwin stuff from platform_test.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9316
2009-03-04 04:15:16 +00:00

63 lines
1.5 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// This program determines which OS that this Valgrind installation
// supports, which depends on what was chosen at configure-time.
//
// We return:
// - 0 if the machine matches the asked-for OS
// - 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)
// Nb: When updating this file for a new OS, add the name to
// 'all_OSes' as well as adding go().
#define False 0
#define True 1
typedef int Bool;
char* all_OSes[] = {
"linux",
"aix5",
NULL
};
static Bool go(char* OS)
{
#if defined(VGO_linux)
if ( 0 == strcmp( OS, "linux" ) ) return True;
#elif defined(VGO_aix5)
if ( 0 == strcmp( OS, "aix5" ) ) return True;
#else
# error Unknown OS
#endif // VGO_*
return False;
}
//---------------------------------------------------------------------------
// main
//---------------------------------------------------------------------------
int main(int argc, char **argv)
{
int i;
if ( argc != 2 ) {
fprintf( stderr, "usage: os_test <OS-type>\n" );
exit(3); // Usage error.
}
if (go( argv[1] )) {
return 0; // Matched.
}
for (i = 0; NULL != all_OSes[i]; i++) {
if ( 0 == strcmp( argv[1], all_OSes[i] ) )
return 1; // Didn't match, but named another OS.
}
return 2; // Didn't match any OSes.
}