Improved PrintArch functions (#595) (#601)

Moved all duplicate 'PrintArch' functions to testHarness.c
Replaced sysctl system call used in 'PrintArch' function with uname
system call

Signed-off-by: bhargavdas <bhargav_das@mentor.com>

Update testHarness.c
This commit is contained in:
Bhargav Das
2020-02-21 22:17:54 +05:30
committed by GitHub
parent 3a628cfae2
commit b2cb18073c
7 changed files with 55 additions and 248 deletions

View File

@@ -99,7 +99,6 @@ static size_t gArgCount;
static int ParseArgs( int argc, const char **argv );
static void PrintArch( void );
static void PrintUsage( void );
test_status InitCL( cl_device_id device );
static void ReleaseCL( void );
@@ -442,63 +441,6 @@ static int ParseArgs( int argc, const char **argv )
return 0;
}
static void PrintArch( void )
{
vlog( "\nHost info:\n" );
vlog( "\tsizeof( void*) = %ld\n", sizeof( void *) );
#if defined( __ppc__ )
vlog( "\tARCH:\tppc\n" );
#elif defined( __ppc64__ )
vlog( "\tARCH:\tppc64\n" );
#elif defined( __PPC__ )
vlog( "ARCH:\tppc\n" );
#elif defined( __i386__ )
vlog( "\tARCH:\ti386\n" );
#elif defined( __x86_64__ )
vlog( "\tARCH:\tx86_64\n" );
#elif defined( __arm__ )
vlog( "\tARCH:\tarm\n" );
#elif defined( __aarch64__ )
vlog( "\tARCH:\taarch64\n" );
#else
vlog( "\tARCH:\tunknown\n" );
#endif
#if defined( __APPLE__ )
int type = 0;
size_t typeSize = sizeof( type );
sysctlbyname( "hw.cputype", &type, &typeSize, NULL, 0 );
vlog( "\tcpu type:\t%d\n", type );
typeSize = sizeof( type );
sysctlbyname( "hw.cpusubtype", &type, &typeSize, NULL, 0 );
vlog( "\tcpu subtype:\t%d\n", type );
#elif defined( __linux__ ) && !defined(__aarch64__)
int _sysctl(struct __sysctl_args *args );
#define OSNAMESZ 100
struct __sysctl_args args;
char osname[OSNAMESZ];
size_t osnamelth;
int name[] = { CTL_KERN, KERN_OSTYPE };
memset(&args, 0, sizeof(struct __sysctl_args));
args.name = name;
args.nlen = sizeof(name)/sizeof(name[0]);
args.oldval = osname;
args.oldlenp = &osnamelth;
osnamelth = sizeof(osname);
if (syscall(SYS__sysctl, &args) == -1) {
vlog( "_sysctl error\n" );
}
else {
vlog("this machine is running %*s\n", osnamelth, osname);
}
#endif
}
static void PrintUsage( void )
{
vlog( "%s [-z]: <optional: test names>\n", appName );