Make 'syslog not supported' a warning vs a fatal error if someone tries to use it on syslog-less platforms; clean up unit & harness tests & handle some per-platform quirks
This commit is contained in:
parent
9b194b5122
commit
2a278ad29b
|
@ -119,8 +119,8 @@ EOT
|
|||
#
|
||||
sub initialize() {
|
||||
|
||||
my $twstr = getPolicyFileString();
|
||||
twtools::GeneratePolicyFile($twstr);
|
||||
my $twstr = getPolicyFileString();
|
||||
twtools::GeneratePolicyFile($twstr);
|
||||
|
||||
}
|
||||
|
||||
|
@ -131,30 +131,36 @@ sub initialize() {
|
|||
#
|
||||
sub run() {
|
||||
|
||||
my $twpassed = 1;
|
||||
twtools::logStatus("*** Beginning $description\n");
|
||||
printf("%-30s", "-- $description");
|
||||
|
||||
twtools::logStatus("*** Beginning $description\n");
|
||||
printf("%-30s", "-- $description");
|
||||
if ($^O eq "skyos") {
|
||||
++$twtools::twskippedtests;
|
||||
print "SKIPPED; TODO: SkyOS has fewer expected changes here; refactor so we can test for correct values\n";
|
||||
return;
|
||||
}
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# Run the tests describe above in the %TESTS structure.
|
||||
#
|
||||
$twpassed = twtools::RunIntegrityTests(%TESTS);
|
||||
my $twpassed = 1;
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# Run the tests describe above in the %TESTS structure.
|
||||
#
|
||||
$twpassed = twtools::RunIntegrityTests(%TESTS);
|
||||
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# See if the tests all succeeded...
|
||||
#
|
||||
if ($twpassed) {
|
||||
#########################################################
|
||||
#
|
||||
# See if the tests all succeeded...
|
||||
#
|
||||
if ($twpassed) {
|
||||
print "PASSED\n";
|
||||
++$twtools::twpassedtests;
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
++$twtools::twfailedtests;
|
||||
print "*FAILED*\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -159,9 +159,11 @@ sub RunBasicTest
|
|||
# Make sure we got 4 violations: 2 mod, 1 add, 1 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = ($^O ne "skyos") ? 4 : 3;
|
||||
my $c_expected = ($^O ne "skyos") ? 2 : 1;
|
||||
|
||||
if( ($n != $n_expected) || ($a != 1) || ($r != 1) || ($c != $c_expected) ) {
|
||||
|
||||
if( ($n != 4) || ($a != 1) || ($r != 1) || ($c != 2) )
|
||||
{
|
||||
twtools::logStatus("FAILED -- initial integrity check had unexpected results\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ EOT
|
|||
#
|
||||
sub initialize() {
|
||||
|
||||
my $twstr = getPolicyFileString();
|
||||
twtools::GeneratePolicyFile($twstr);
|
||||
my $twstr = getPolicyFileString();
|
||||
twtools::GeneratePolicyFile($twstr);
|
||||
|
||||
}
|
||||
|
||||
|
@ -89,30 +89,36 @@ sub initialize() {
|
|||
#
|
||||
sub run() {
|
||||
|
||||
my $twpassed = 1;
|
||||
twtools::logStatus("*** Beginning $description\n");
|
||||
printf("%-30s", "-- $description");
|
||||
|
||||
twtools::logStatus("*** Beginning $description\n");
|
||||
printf("%-30s", "-- $description");
|
||||
if ($^O eq "skyos" || $^O eq "haiku") {
|
||||
++$twtools::twskippedtests;
|
||||
print "SKIPPED; OS doesn't support hardlinks.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# Run the tests describe above in the %TESTS structure.
|
||||
#
|
||||
$twpassed = twtools::RunIntegrityTests(%TESTS);
|
||||
my $twpassed = 1;
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# Run the tests describe above in the %TESTS structure.
|
||||
#
|
||||
$twpassed = twtools::RunIntegrityTests(%TESTS);
|
||||
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# See if the tests all succeeded...
|
||||
#
|
||||
if ($twpassed) {
|
||||
#########################################################
|
||||
#
|
||||
# See if the tests all succeeded...
|
||||
#
|
||||
if ($twpassed) {
|
||||
++$twtools::twpassedtests;
|
||||
print "PASSED\n";
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
++$twtools::twfailedtests;
|
||||
print "*FAILED*\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ sub PrepareForTest
|
|||
sub run
|
||||
{
|
||||
my $twpassed = 1;
|
||||
my $dir_mods = ($^O eq "skyos") ? 0 : 1;
|
||||
|
||||
twtools::logStatus("*** Beginning integrity check test\n");
|
||||
printf("%-30s", "-- $description");
|
||||
|
@ -181,8 +182,10 @@ sub run
|
|||
# Make sure we got 6 violations: 3 mod, 1 add, 2 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = $dir_mods ? 6 : 4;
|
||||
my $c_expected = $dir_mods ? 3 : 1;
|
||||
|
||||
if( ($n != 6) || ($a != 1) || ($r != 2) || ($c != 3) )
|
||||
if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) )
|
||||
{
|
||||
twtools::logStatus("Full IC failed: $n $a $r $c\n");
|
||||
$twpassed = 0;
|
||||
|
@ -213,8 +216,10 @@ sub run
|
|||
# Make sure we got 6 violations: 3 mod, 1 add, 2 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = $dir_mods ? 6 : 4;
|
||||
my $c_expected = $dir_mods ? 3 : 1;
|
||||
|
||||
if( ($n != 6) || ($a != 1) || ($r != 2) || ($c != 3) )
|
||||
if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) )
|
||||
{
|
||||
twtools::logStatus("IC with FS section failed: $n $a $r $c\n");
|
||||
$twpassed = 0;
|
||||
|
@ -229,8 +234,10 @@ sub run
|
|||
# Make sure we got 6 violations: 3 mod, 1 add, 2 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = $dir_mods ? 6 : 4;
|
||||
my $c_expected = $dir_mods ? 3 : 1;
|
||||
|
||||
if( ($n != 6) || ($a != 1) || ($r != 2) || ($c != 3) )
|
||||
if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) )
|
||||
{
|
||||
twtools::logStatus("IC with FS section failed: $n $a $r $c\n");
|
||||
$twpassed = 0;
|
||||
|
@ -245,8 +252,10 @@ sub run
|
|||
# Make sure we got 4 violations this time: 2 mod, 1 add, 1 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = $dir_mods ? 4 : 3;
|
||||
my $c_expected = $dir_mods ? 2 : 1;
|
||||
|
||||
if( ($n != 4) || ($a != 1) || ($r != 1) || ($c != 2) )
|
||||
if( ($n != $n_expected) || ($a != 1) || ($r != 1) || ($c != $c_expected) )
|
||||
{
|
||||
twtools::logStatus("IC of Rule A failed: $n $a $r $c\n");
|
||||
$twpassed = 0;
|
||||
|
@ -261,8 +270,10 @@ sub run
|
|||
# Make sure we got 2 violations this time: 1 mod, 0 add, 1 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = $dir_mods ? 2 : 1;
|
||||
my $c_expected = $dir_mods ? 1 : 0;
|
||||
|
||||
if( ($n != 2) || ($a != 0) || ($r != 1) || ($c != 1) )
|
||||
if( ($n != $n_expected) || ($a != 0) || ($r != 1) || ($c != $c_expected) )
|
||||
{
|
||||
twtools::logStatus("IC of severity 200+ failed: $n $a $r $c\n");
|
||||
$twpassed = 0;
|
||||
|
@ -277,8 +288,10 @@ sub run
|
|||
# Make sure we got 2 violations this time: 1 mod, 0 add, 1 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = $dir_mods ? 2 : 1;
|
||||
my $c_expected = $dir_mods ? 1 : 0;
|
||||
|
||||
if( ($n != 2) || ($a != 0) || ($r != 1) || ($c != 1) )
|
||||
if( ($n != $n_expected) || ($a != 0) || ($r != 1) || ($c != $c_expected) )
|
||||
{
|
||||
twtools::logStatus("IC of severity 'high' failed: $n $a $r $c\n");
|
||||
$twpassed = 0;
|
||||
|
@ -314,8 +327,10 @@ sub run
|
|||
# Make sure we got 6 violations: 3 mod, 1 add, 2 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = $dir_mods ? 6 : 4;
|
||||
my $c_expected = $dir_mods ? 3 : 1;
|
||||
|
||||
if( ($n != 6) || ($a != 1) || ($r != 2) || ($c != 3) )
|
||||
if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) )
|
||||
{
|
||||
twtools::logStatus("Full IC failed: $n $a $r $c\n");
|
||||
$twpassed = 0;
|
||||
|
@ -328,11 +343,13 @@ sub run
|
|||
RemoveFile("$reportloc");
|
||||
twtools::RunIntegrityCheck({trailing-opts => "-I -V cat -P $twtools::twlocalpass"});
|
||||
|
||||
# Make sure we got 1 violation this time: 1 mod, 0 add, 0 rm.
|
||||
# Make sure we got 6 violations: 3 mod, 1 add, 2 rm.
|
||||
#
|
||||
my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() );
|
||||
my $n_expected = $dir_mods ? 6 : 4;
|
||||
my $c_expected = $dir_mods ? 3 : 1;
|
||||
|
||||
if( ($n != 6) || ($a != 1) || ($r != 2) || ($c != 3) )
|
||||
if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) )
|
||||
{
|
||||
twtools::logStatus("Interactive IC failed: $n $a $r $c\n");
|
||||
$twpassed = 0;
|
||||
|
|
|
@ -71,8 +71,8 @@ EOT
|
|||
|
||||
sub initialize() {
|
||||
|
||||
my $twstr = getPolicyFileString();
|
||||
twtools::GeneratePolicyFile($twstr);
|
||||
my $twstr = getPolicyFileString();
|
||||
twtools::GeneratePolicyFile($twstr);
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,32 +83,37 @@ sub initialize() {
|
|||
#
|
||||
sub run() {
|
||||
|
||||
my $twpassed = 1;
|
||||
twtools::logStatus("\n\n*** Beginning $description\n");
|
||||
printf("%-30s", "-- $description");
|
||||
|
||||
twtools::logStatus("\n\n*** Beginning $description\n");
|
||||
if ($^O eq "skyos") {
|
||||
++$twtools::twskippedtests;
|
||||
print "SKIPPED; SkyOS doesn't support readonly files.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%-30s", "-- $description");
|
||||
my $twpassed = 1;
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# Run the tests describe above in the %TESTS structure.
|
||||
#
|
||||
$twpassed = twtools::RunIntegrityTests(%TESTS);
|
||||
#########################################################
|
||||
#
|
||||
# Run the tests describe above in the %TESTS structure.
|
||||
#
|
||||
$twpassed = twtools::RunIntegrityTests(%TESTS);
|
||||
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# See if the tests all succeeded...
|
||||
#
|
||||
if ($twpassed) {
|
||||
#########################################################
|
||||
#
|
||||
# See if the tests all succeeded...
|
||||
#
|
||||
if ($twpassed) {
|
||||
++$twtools::twpassedtests;
|
||||
print "PASSED\n";
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
print "*FAILED*\n";
|
||||
++$twtools::twfailedtests;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,10 +37,13 @@ sub run() {
|
|||
$twpassed = 0;
|
||||
}
|
||||
|
||||
twtools::logStatus(`mkfifo $twtools::twrootdir/donthashme.fifo`);
|
||||
if ( $? != 0 ) {
|
||||
twtools::logStatus("test fifo creation failed\n");
|
||||
$twpassed = 0;
|
||||
# SkyOS doesn't have FIFOs, so this won't work
|
||||
if ( $^O ne "skyos") {
|
||||
twtools::logStatus(`mkfifo $twtools::twrootdir/donthashme.fifo`);
|
||||
if ( $? != 0 ) {
|
||||
twtools::logStatus("test fifo creation failed\n");
|
||||
$twpassed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
twtools::logStatus(`$twtools::twrootdir/bin/siggen`);
|
||||
|
|
|
@ -189,7 +189,7 @@ sub AddEncryption {
|
|||
|
||||
my ($filename) = @_;
|
||||
logStatus "addding crypt to file...\n";
|
||||
logStatus(`$twrootdir/bin/twadmin -m E -c $twrootdir/$twcfgloc -P $twlocalpass -Q $twsitepass $filename`);
|
||||
logStatus(`$twrootdir/bin/twadmin -m E -c $twrootdir/$twcfgloc -P $twlocalpass -Q $twsitepass $filename 2>&1`);
|
||||
|
||||
return ($? == 0);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ sub RemoveEncryption {
|
|||
my ($filename) = @_;
|
||||
|
||||
logStatus "removing crypto from file...\n";
|
||||
logStatus(`$twrootdir/bin/twadmin -m R -c $twrootdir/$twcfgloc -P $twlocalpass -Q $twsitepass $filename`);
|
||||
logStatus(`$twrootdir/bin/twadmin -m R -c $twrootdir/$twcfgloc -P $twlocalpass -Q $twsitepass $filename 2>&1`);
|
||||
|
||||
return ($? == 0);
|
||||
}
|
||||
|
|
|
@ -446,14 +446,19 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
|
|||
// SYSLOG reporting
|
||||
if(cf.Lookup(TSTRING(_T("SYSLOGREPORTING")), str))
|
||||
{
|
||||
#if SUPPORTS_SYSLOG
|
||||
if (_tcsicmp(str.c_str(), _T("true")) == 0)
|
||||
{
|
||||
#if SUPPORTS_SYSLOG
|
||||
pModeInfo->mbLogToSyslog = true;
|
||||
#else
|
||||
eTWSyslogNotSupported e;
|
||||
e.SetFatality(false);
|
||||
cErrorReporter::PrintErrorMsg(e);
|
||||
pModeInfo->mbLogToSyslog = false;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
pModeInfo->mbLogToSyslog = false;
|
||||
#else
|
||||
throw eTWSyslogNotSupported();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -197,6 +197,6 @@ void TestConfigFile2(void)
|
|||
|
||||
void RegisterSuite_ConfigFile()
|
||||
{
|
||||
RegisterTest("ConfigFile", "Basic 1", TestConfigFile);
|
||||
RegisterTest("ConfigFile", "Basic 2", TestConfigFile2);
|
||||
RegisterTest("ConfigFile", "Basic1", TestConfigFile);
|
||||
RegisterTest("ConfigFile", "Basic2", TestConfigFile2);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ static void util_TestUnprintable( const TSTRING& strCUnprintable )
|
|||
TSTRING strEncoded = strCUnprintable;
|
||||
|
||||
e.Encode( strEncoded );
|
||||
TCOUT << strEncoded << std::endl;
|
||||
// TCOUT << strEncoded << std::endl;
|
||||
TSTRING strOut = strEncoded;
|
||||
e.Decode( strOut );
|
||||
|
||||
|
@ -246,7 +246,7 @@ void TestQuoteAndBackSlash()
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Basic
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
void TestDisplayEncoderBasic()
|
||||
void TestDisplayEncoderBasic1()
|
||||
{
|
||||
//=============================================================
|
||||
// TEST UNPRINTABLE ENCODING/ROUNDTRIP
|
||||
|
@ -269,7 +269,10 @@ void TestDisplayEncoderBasic()
|
|||
util_TestUnprintable( _T("\xEE\xEEtwo big") );
|
||||
util_TestUnprintable( _T("small\x01") );
|
||||
util_TestUnprintable( _T("\x01\x01two small") );
|
||||
|
||||
}
|
||||
|
||||
void TestDisplayEncoderBasic2()
|
||||
{
|
||||
//=============================================================
|
||||
// TEST UNCONVERTABLE CHARS
|
||||
//=============================================================
|
||||
|
@ -284,7 +287,10 @@ void TestDisplayEncoderBasic()
|
|||
}
|
||||
}
|
||||
util_TestUnprintable( strMessWithMe );
|
||||
}
|
||||
|
||||
void TestDisplayEncoderBasic3()
|
||||
{
|
||||
//=============================================================
|
||||
// TEST \\ and \x ENCODING/ROUNDTRIP
|
||||
//=============================================================
|
||||
|
@ -298,8 +304,10 @@ void TestDisplayEncoderBasic()
|
|||
util_TestUnprintable( _T("Tri\\xcky") );
|
||||
util_TestUnprintable( _T("Tricky\\x") );
|
||||
util_TestUnprintable( _T("\\Tricky\\\\x") );
|
||||
}
|
||||
|
||||
|
||||
void TestDisplayEncoderBasic4()
|
||||
{
|
||||
//=============================================================
|
||||
// TEST UNCONVERTABLE, UNPRINTABLE, AND \\ and \" CHARS
|
||||
//=============================================================
|
||||
|
@ -323,7 +331,10 @@ void TestDisplayEncoderBasic()
|
|||
|
||||
void RegisterSuite_DisplayEncoder()
|
||||
{
|
||||
RegisterTest("DisplayEncoder", "Basic", TestDisplayEncoderBasic);
|
||||
RegisterTest("DisplayEncoder", "Basic1", TestDisplayEncoderBasic1);
|
||||
RegisterTest("DisplayEncoder", "Basic2", TestDisplayEncoderBasic2);
|
||||
RegisterTest("DisplayEncoder", "Basic3", TestDisplayEncoderBasic3);
|
||||
RegisterTest("DisplayEncoder", "Basic4", TestDisplayEncoderBasic4);
|
||||
RegisterTest("DisplayEncoder", "CharToHex", TestCharToHex);
|
||||
RegisterTest("DisplayEncoder", "HexToChar", TestHexToChar);
|
||||
RegisterTest("DisplayEncoder", "StringToHex", TestStringToHex);
|
||||
|
|
|
@ -44,16 +44,16 @@ void TestError()
|
|||
bool threw = false;
|
||||
try
|
||||
{
|
||||
std::cout << "Before Exception" << std::endl;
|
||||
std::cout << "Line number before throw: " << __LINE__ << std::endl;
|
||||
// std::cout << "Before Exception" << std::endl;
|
||||
// std::cout << "Line number before throw: " << __LINE__ << std::endl;
|
||||
throw eErrorGeneral(_T("This is an error!"));
|
||||
std::cout << "After Exception" << std::endl;
|
||||
// std::cout << "After Exception" << std::endl;
|
||||
}
|
||||
catch(eError& e)
|
||||
{
|
||||
threw = true;
|
||||
TEST(_tcscmp(e.GetMsg().c_str(), _T("This is an error!")) == 0);
|
||||
TCOUT << _T("Exception caught!\n\nID=") << e.GetID() << _T("\n\t") << e.GetMsg() << std::endl;
|
||||
// TCOUT << _T("Exception caught!\n\nID=") << e.GetID() << _T("\n\t") << e.GetMsg() << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ void TestError()
|
|||
{
|
||||
threw = true;
|
||||
TEST(_tcscmp(e.GetMsg().c_str(), _T("error_t.cpp")) == 0);
|
||||
TCOUT << _T("Internal error caught!\n\nID=") << e.GetID() << _T("\n\t") << e.GetMsg() << std::endl;
|
||||
// TCOUT << _T("Internal error caught!\n\nID=") << e.GetID() << _T("\n\t") << e.GetMsg() << std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "core/archive.h"
|
||||
#include "fco/genreswitcher.h"
|
||||
|
||||
void TestFCOName()
|
||||
void TestFCOName1()
|
||||
{
|
||||
// test the relationship operator...
|
||||
cFCOName above (_T("/etc"));
|
||||
|
@ -82,7 +82,10 @@ void TestFCOName()
|
|||
TEST(_tcscmp(cat.Pop(),_T("cat")) == 0);
|
||||
TEST(dog.AsString().compare(cat.AsString()) == 0);
|
||||
TEST(dog.GetRelationship(cat) == cFCOName::REL_EQUAL);
|
||||
}
|
||||
|
||||
void TestFCOName2()
|
||||
{
|
||||
cFCOName nullName;
|
||||
TEST(*nullName.AsString().c_str() == 0);
|
||||
|
||||
|
@ -141,5 +144,6 @@ void TestFCOName()
|
|||
|
||||
void RegisterSuite_FCOName()
|
||||
{
|
||||
RegisterTest("FCOName", "Basic", TestFCOName);
|
||||
RegisterTest("FCOName", "Basic1", TestFCOName1);
|
||||
RegisterTest("FCOName", "Basic2", TestFCOName2);
|
||||
}
|
||||
|
|
|
@ -41,15 +41,11 @@ using namespace std;
|
|||
|
||||
void TestFCOSpec()
|
||||
{
|
||||
cout << "Begin\tTestFCOSpec" << endl;
|
||||
// all it seems I can test here is that the default mask works
|
||||
const iFCOSpecMask* pDefMask = iFCOSpecMask::GetDefaultMask();
|
||||
TEST(pDefMask->GetName().compare(TSTRING(_T("Default"))) == 0);
|
||||
TEST(pDefMask->GetName().compare( TSTRING(_T("Default")) ) == 0);
|
||||
iFCO* pf1 = (iFCO*)0xbad, *pf2 = (iFCO*)0xcab;
|
||||
TEST( pDefMask->Accept(pf1) && pDefMask->Accept(pf2) );
|
||||
|
||||
cout << "End\tTestFCOSpec" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
void RegisterSuite_FCOSpec()
|
||||
|
|
|
@ -78,6 +78,7 @@ void TestFCOSpecImpl1()
|
|||
pSpec->SetStartPoint(cFCOName(TwTestDir()));
|
||||
|
||||
dataSrc.SeekToFCO(pSpec->GetStartPoint(), false);
|
||||
TEST(!dataSrc.Done());
|
||||
iFCO* pFCO = dataSrc.CreateFCO();
|
||||
TEST(pFCO);
|
||||
//PrintFCOTree(pFCO, d, 0);
|
||||
|
@ -101,6 +102,7 @@ void TestFCOSpecImpl2()
|
|||
pSet->Add(cFCOName(_T("/etc/pclient")));
|
||||
|
||||
dataSrc.SeekToFCO(pSpec->GetStartPoint(), false);
|
||||
TEST(!dataSrc.Done());
|
||||
iFCO* pFCO = dataSrc.CreateFCO();
|
||||
TEST(pFCO);
|
||||
//PrintFCOTree(pFCO, d, 0);
|
||||
|
|
|
@ -48,17 +48,17 @@ void TestGrowHeap()
|
|||
cGrowHeap gh( initSize, growBy, _T("growheap_t.cpp") );
|
||||
|
||||
// report initial state
|
||||
TCOUT << _T("Initial size: ") << initSize << endl;
|
||||
/* TCOUT << _T("Initial size: ") << initSize << endl;
|
||||
TCOUT << _T("Growby: ") << growBy << endl;
|
||||
TCOUT << _T("Initial Growheap memory usage: ") << gh.TotalMemUsage() << endl << endl;
|
||||
|
||||
*/
|
||||
const int growFactor = 5; // how much to enlarge requests each time
|
||||
// make it odd so we can see if the growheap
|
||||
// rounds to the alignment size
|
||||
for( size_t size = 1; size < growBy; size *= growFactor )
|
||||
{
|
||||
// allocate memory
|
||||
TCOUT << _T("Allocing by ") << size << endl;
|
||||
//TCOUT << _T("Allocing by ") << size << endl;
|
||||
void* p = gh.Malloc( size );
|
||||
TEST( p != NULL );
|
||||
|
||||
|
@ -66,12 +66,12 @@ void TestGrowHeap()
|
|||
if( size > sizeof(int) )
|
||||
{
|
||||
// read from memory
|
||||
TCOUT << _T("Reading an int from memory...") << endl;
|
||||
//TCOUT << _T("Reading an int from memory...") << endl;
|
||||
int* pi = static_cast< int* >( p );
|
||||
int i = *pi;
|
||||
|
||||
// write to memory
|
||||
TCOUT << _T("Writing an int to memory...") << endl;
|
||||
//TCOUT << _T("Writing an int to memory...") << endl;
|
||||
*pi = i;
|
||||
}
|
||||
|
||||
|
@ -79,19 +79,21 @@ void TestGrowHeap()
|
|||
if( size > sizeof(double) )
|
||||
{
|
||||
// read from memory
|
||||
TCOUT << _T("Reading a double from memory...") << endl;
|
||||
//TCOUT << _T("Reading a double from memory...") << endl;
|
||||
double* pd = static_cast< double* >( p );
|
||||
double d = *pd;
|
||||
|
||||
// write to memory
|
||||
TCOUT << _T("Writing a double to memory...") << endl;
|
||||
//TCOUT << _T("Writing a double to memory...") << endl;
|
||||
*pd = d;
|
||||
}
|
||||
|
||||
// report total usage
|
||||
TCOUT << _T("Growheap memory usage: ") << gh.TotalMemUsage() << endl << endl;
|
||||
//TCOUT << _T("Growheap memory usage: ") << gh.TotalMemUsage() << endl << endl;
|
||||
}
|
||||
|
||||
TEST( gh.TotalMemUsage() > 0);
|
||||
|
||||
// free memory
|
||||
gh.Clear();
|
||||
TEST( gh.TotalMemUsage() == 0 );
|
||||
|
|
|
@ -82,7 +82,7 @@ AlignMe<ALIGN_SIZE>::AlignMe()
|
|||
// this test exists in the first place.
|
||||
// -bcox
|
||||
#if (!IS_HPUX && !IS_SOLARIS) //Turns out Solaris SPARC is unhappy with this test too, btw
|
||||
TCOUT << _T("Testing alignment of size ") << ALIGN_SIZE << std::endl;
|
||||
//TCOUT << _T("Testing alignment of size ") << ALIGN_SIZE << std::endl;
|
||||
|
||||
// access a double in the byte array to see if it is aligned. if it isn't and the CPU
|
||||
// can't handle it, you'll get a bus error
|
||||
|
@ -90,11 +90,11 @@ AlignMe<ALIGN_SIZE>::AlignMe()
|
|||
// this should choke if the CPU can't
|
||||
// handle misaligned memory access
|
||||
int32* pi = (int32*)&a[ALIGN_SIZE];
|
||||
TCOUT << _T("Testing alignment of an int32...") << std::endl;
|
||||
TCOUT << _T("Reading...") << std::endl;
|
||||
//TCOUT << _T("Testing alignment of an int32...") << std::endl;
|
||||
//TCOUT << _T("Reading...") << std::endl;
|
||||
int32 i = *pi; // access memory for read
|
||||
TCOUT << _T("Read succeeded.") << std::endl;
|
||||
TCOUT << _T("Writing...") << std::endl;
|
||||
//TCOUT << _T("Read succeeded.") << std::endl;
|
||||
//TCOUT << _T("Writing...") << std::endl;
|
||||
*pi = i; // access memory for write
|
||||
TCOUT << _T("Write succeeded.") << std::endl;
|
||||
|
||||
|
@ -102,17 +102,17 @@ AlignMe<ALIGN_SIZE>::AlignMe()
|
|||
// this should choke if the CPU can't
|
||||
// handle misaligned memory access
|
||||
int64* pb = (int64*)&a[ALIGN_SIZE];
|
||||
TCOUT << _T("Testing alignment of an int64...") << std::endl;
|
||||
TCOUT << _T("Reading...") << std::endl;
|
||||
//TCOUT << _T("Testing alignment of an int64...") << std::endl;
|
||||
//TCOUT << _T("Reading...") << std::endl;
|
||||
int64 I = *pb; // access memory for read
|
||||
TCOUT << _T("Read succeeded") << std::endl;
|
||||
TCOUT << _T("Writing...") << std::endl;
|
||||
//TCOUT << _T("Read succeeded") << std::endl;
|
||||
//TCOUT << _T("Writing...") << std::endl;
|
||||
*pb = I; // access memory for write
|
||||
TCOUT << _T("Write succeeded.") << std::endl;
|
||||
//TCOUT << _T("Write succeeded.") << std::endl;
|
||||
|
||||
|
||||
TCOUT << _T("Alignment of ") << ALIGN_SIZE << _T(" ") << ( ALIGN_SIZE == 1 ? _T("byte") : _T("bytes") ) << _T(" is OK") << std::endl
|
||||
<< _T("=========================================\n");
|
||||
/*TCOUT << _T("Alignment of ") << ALIGN_SIZE << _T(" ") << ( ALIGN_SIZE == 1 ? _T("byte") : _T("bytes") ) << _T(" is OK") << std::endl
|
||||
<< _T("=========================================\n"); */
|
||||
|
||||
TEST("Aligned"); // The actual test is not bus erroring up above; this just tells the framework we tested something.
|
||||
|
||||
|
@ -131,8 +131,8 @@ void TestAlignment()
|
|||
// The last AlignMe to be successfully constructed
|
||||
// - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
TCOUT << _T("Testing for byte alignment\n")
|
||||
<< _T("=========================================\n");
|
||||
// TCOUT << _T("Testing for byte alignment\n")
|
||||
// << _T("=========================================\n");
|
||||
|
||||
AlignMe<128> a128;
|
||||
AlignMe<64> a64;
|
||||
|
@ -156,10 +156,10 @@ void TestAlignment()
|
|||
a[0] = 0xAB;
|
||||
|
||||
|
||||
TCOUT << _T("=========================================\n")
|
||||
/* TCOUT << _T("=========================================\n")
|
||||
<< _T("About to test memory access off by 1 byte\n")
|
||||
<< _T("If you do not see a confirmation after this line, the test choked")
|
||||
<< std::endl;
|
||||
<< std::endl; */
|
||||
|
||||
// this should choke if the CPU can't
|
||||
// handle misaligned memory access
|
||||
|
@ -180,20 +180,20 @@ void TestAlignment()
|
|||
// this should be fine
|
||||
b[0] = 0xAB;
|
||||
|
||||
TCOUT << _T("=========================================\n")
|
||||
/* TCOUT << _T("=========================================\n")
|
||||
<< _T("About to test memory access off by ") << BYTE_ALIGN
|
||||
<< _T(" ") << ( BYTE_ALIGN == 1 ? _T("byte") : _T("bytes") ) << std::endl
|
||||
<< _T("If you do not see a confirmation after this line, the test choked")
|
||||
<< std::endl;
|
||||
|
||||
*/
|
||||
// this should choke if the CPU can't
|
||||
// handle misaligned memory access
|
||||
pi = (int32*)&b[BYTE_ALIGN];
|
||||
*pi = *pi; // aligned (hopefully) access (read and write)
|
||||
|
||||
TCOUT << _T("Aligned access OK. BYTE_ALIGN value of ") << BYTE_ALIGN << _T(" is good.") << std::endl;
|
||||
/* TCOUT << _T("Aligned access OK. BYTE_ALIGN value of ") << BYTE_ALIGN << _T(" is good.") << std::endl;
|
||||
TCOUT << _T("=========================================\n");
|
||||
TEST("BYTE_ALIGN ok"); // yet again, the test is not falling over a couple of lines up.
|
||||
TEST("BYTE_ALIGN ok"); // yet again, the test is not falling over a couple of lines up. */
|
||||
}
|
||||
|
||||
// Not sure this is a super valuable test, since it just verifies that builtin integer types
|
||||
|
|
|
@ -443,10 +443,6 @@ void assertSHA1(const std::string& source, const std::string& expectedHex)
|
|||
shaSig.Update( (const byte*)source.c_str(), source.length() );
|
||||
shaSig.Finit();
|
||||
|
||||
TCERR << "Source = [" << source << "]" << std::endl;
|
||||
TCERR << "Expected = " << expectedHex << std::endl;
|
||||
TCERR << "Observed = " << shaSig.AsStringHex() << std::endl;
|
||||
|
||||
TEST( shaSig.AsStringHex() == expectedHex);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,9 +86,9 @@ void OutputString( TSTRING& str )
|
|||
{
|
||||
cQuoteEncoder qe;
|
||||
|
||||
TCOUT << _T("Plain string: <") << str << _T(">") << endl;
|
||||
/* TCOUT << _T("Plain string: <") << str << _T(">") << endl;
|
||||
TCOUT << _T("Encoded string: <") << qe.Encode( str ) << _T(">") << endl;
|
||||
TCOUT << _T("Decoded string: <") << qe.Unencode( str ) << _T(">") << endl << endl ;
|
||||
TCOUT << _T("Decoded string: <") << qe.Unencode( str ) << _T(">") << endl << endl ; */
|
||||
|
||||
TEST( str == qe.Unencode(qe.Encode(str)) );
|
||||
}
|
||||
|
|
|
@ -479,6 +479,7 @@ int _tmain(int argc, TCHAR** argv)
|
|||
//TEST(cRefCountObj::AllRefCountObjDestoryed() == true);
|
||||
|
||||
std::cout << std::endl << "Ran " << ran_count << " unit tests with " << failed_count << " failures, " << skipped_count << " skipped." << std::endl;
|
||||
std::cout << "(total test assertions: " << macro_count << ")" << std::endl;
|
||||
|
||||
if (failed_count)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue