50 void copyFile(
string dstFile,
string srcFile )
52 ifstream src(srcFile.c_str(), ios_base::binary);
53 ofstream dst(dstFile.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
56 while( src.get(ch)) dst.put(ch);
58 if( !src.eof() || !dst )
throw exception();
64 fh=fopen(fileName.c_str(),
"rb");
74 string programDirname = getCppunitTopDirectory();
75 string writeDirectory = getWritableDirectory();
77 string testInput = programDirname + getTestDirectory() +
"/testInput.xml";
79 testInput = getTestDirectory() +
"/testInput.xml";
83 string memdumpOrigFile = programDirname + getTestDirectory() +
"/memdump.dat";
85 memdumpOrigFile = getTestDirectory() +
"/memdump.dat";
86 string memdumpCopyFile = writeDirectory +
"/memdump-copy.dat";
87 copyFile( memdumpCopyFile, memdumpOrigFile );
91 string cmosOrigFile = programDirname + getTestDirectory() +
"/cmos.dat";
93 cmosOrigFile = getTestDirectory() +
"/cmos.dat";
94 string cmosCopyFile = writeDirectory +
"/cmos-copy.dat";
95 copyFile( cmosCopyFile, cmosOrigFile );
98 string smiOutput = writeDirectory +
"/smi-output.dat";
169 catch (
const exception &)
189 while( token != tokenTable->
end() )
197 bool doUpdate =
false;
214 ASSERT_THROWS( (*tokenTable) [
"la la la"], smbios::NotImplemented );
215 ASSERT_THROWS( (*tokenTableC)[
"la la la"], smbios::NotImplemented );
218 (void) tokenTableC[0xFE];
221 ost << *tokenTable << endl;
222 ost << *tokenTableC << endl;
226 while( tokenC != tokenTableC->
end() )
237 bool doUpdate =
false;
242 while( token != tokenTable->
end() )
247 const char *testStr =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnop";
248 const u8 *testStrU8 =
reinterpret_cast<const u8*
>(testStr);
260 myStr1 =
new u8[ size ];
261 memset( myStr1, 0, size );
267 catch(
const smi::UnhandledSmi &)
273 token->
setString( testStrU8, strlen(testStr) + 1 );
275 CPPUNIT_ASSERT( size <= strlen(testStr)+1 );
277 myStr =
new u8[ size ];
278 memset( myStr, 0, size );
282 if( 0 != memcmp( testStr, reinterpret_cast<char*>(myStr), size - 1 ) )
286 ost <<
"String set on token failed." << endl;
287 ost << (*token) << endl;
288 ost <<
"Size of string to compare is: " << size-1 << endl;
289 ost <<
"Original data: (" << myStr1 <<
")" << endl;
290 ost <<
"Wrote : (" << testStr <<
")" << endl;
291 ost <<
"Read back : (" << myStr <<
")" << endl;
292 CPPUNIT_FAIL( ost.str().c_str() );
314 catch(
const smi::UnhandledSmi &)
321 ost <<
"Failed to SET bit token. Token data: " << endl;
323 CPPUNIT_FAIL( ost.str().c_str() );
335 CPPUNIT_ASSERT( before == after );
359 const char *systemName = 0;
360 const char *serviceTag = 0;
361 const char *assetTag = 0;
362 const char *biosVersion = 0;
363 const char *vendorName = 0;
381 CPPUNIT_ASSERT(systemId != 0);
382 CPPUNIT_ASSERT(systemName != 0);
385 CPPUNIT_ASSERT(biosVersion != 0);
386 CPPUNIT_ASSERT(vendorName != 0);
415 string foundString =
"";
423 catch(
const exception & )
439 string idStr = getTestInputString(
"idByte");
440 int id = strtol( idStr.c_str(), 0, 0);
442 CPPUNIT_ASSERT_EQUAL (
id, systemId );
449 string fromSystem =
"";
464 string testInput = getTestInputString(
"systemName" );
466 CPPUNIT_ASSERT_EQUAL ( testInput, fromSystem );
476 string testInput = getTestInputString(
"serviceTag" );
478 CPPUNIT_ASSERT_EQUAL ( testInput, fromSystem );
492 string testInput = getTestInputString(
"serviceTag" );
494 CPPUNIT_ASSERT_EQUAL ( testInput, fromSystem );
496 string rawCMOSOrig(
"");
501 catch(
const exception &)
508 CPPUNIT_ASSERT_EQUAL ( testInput, rawCMOSOrig );
510 string tagToSet, shouldBe, rawCMOSNew;
513 tagToSet = shouldBe =
"NEWTG";
516 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
519 tagToSet = shouldBe =
"BCDFGHJ";
522 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
525 tagToSet = shouldBe =
"KLMNPQR";
528 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
531 tagToSet = shouldBe =
"STVWXYZ";
534 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
537 tagToSet = shouldBe =
"A";
540 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
543 tagToSet = shouldBe =
"AB";
546 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
549 tagToSet = shouldBe =
"ABC";
552 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
555 tagToSet = shouldBe =
"ABCD";
558 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
562 shouldBe =
"12DFGH0";
566 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
569 tagToSet = shouldBe =
"XGYZYYY";
572 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
575 tagToSet =
"MNPQMNPQ";
576 shouldBe =
"MNPQMNP";
579 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
582 tagToSet =
"ABEIOUD";
583 shouldBe =
"AB0000D";
586 CPPUNIT_ASSERT_EQUAL ( shouldBe, rawCMOSNew );
601 string testInput = getTestInputString(
"assetTag" );
602 CPPUNIT_ASSERT_EQUAL ( testInput, fromSystem );
604 string tagToSet =
"1234567890";
612 CPPUNIT_ASSERT_EQUAL ( tagToSet, fromSystem );
614 catch (
const exception &)
627 string testInput = getTestInputString(
"biosVersion" );
629 CPPUNIT_ASSERT_EQUAL ( testInput, fromSystem );
641 string strval = getTestInputString(
"isDellSystem" );
642 int isDellExpected = strtol( strval.c_str(), 0, 0);
644 CPPUNIT_ASSERT_EQUAL ( isDell, isDellExpected );
661 string versionStr=
"";
662 string releaseStr=
"";
680 catch(
const exception & )
693 CPPUNIT_ASSERT_EQUAL( vendorStr, string1 );
694 CPPUNIT_ASSERT_EQUAL( versionStr, string2 );
695 CPPUNIT_ASSERT_EQUAL( releaseStr, string3 );
697 CPPUNIT_ASSERT_EQUAL( string1, string4 );
698 CPPUNIT_ASSERT_EQUAL( string2, string5 );
699 CPPUNIT_ASSERT_EQUAL( string3, string6 );
809 catch(
const exception & )
843 catch(
const exception & )
852 int tableEntriesCounted = 0;
854 while( item != table->
end() )
856 tableEntriesCounted++;
883 catch(
const exception & )