Merge branch 'dev/2435' of https://github.com/Tripwire/tripwire-open-source into dev/2435
This commit is contained in:
commit
a0d04d89ad
|
@ -1,3 +1,11 @@
|
|||
2017-03-30 Brian Cox <bcox@tripwire.com>
|
||||
* Bump version to 2.4.3.5
|
||||
* Fix ‘install-strip’, ‘check’, ‘uninstall’, and ‘distcheck’ make targets.
|
||||
* Fix GCC 7.0.x warnings; use std::unique_ptr instead of deprecated std::auto_ptr where available.
|
||||
* Add ‘--disable-extrawarnings’ configure option, for old compilers that don’t support the ’-Wextra’ compile option.
|
||||
* Clean up unit tests & enable disabled tests.
|
||||
* Address more static analyzer warnings, including from CppCheck & Flawfinder
|
||||
|
||||
2017-03-05 Brian Cox <bcox@tripwire.com>
|
||||
* Bump version to 2.4.3.4
|
||||
* Fix issue with printing level 2 reports, introduced by fixing a Clang static analyzer quibble in 2.4.3.3. Sigh.
|
||||
|
|
40
ReadMe-2.4.3
40
ReadMe-2.4.3
|
@ -1,4 +1,14 @@
|
|||
What's new in Open Source Tripwire 2.4.3.2:
|
||||
What's new in Open Source Tripwire 2.4.3.x:
|
||||
|
||||
* Useful ‘install-strip’, ‘check’, ‘uninstall’ & ‘distcheck’ make targets as of OST 2.4.3.5. Check target invokes both the test-harness framework and twtest unit tests.
|
||||
|
||||
* Verify OST builds without errors w/ GCC 7.0.x; fix new warnings from the new compiler, including deprecation warnings; use std::unique_ptr instead of std::auto_ptr where available.
|
||||
|
||||
* Add ‘--disable-extrawarnings’ configure option, for old compilers that don’t support the ’-Wextra’ compile option.
|
||||
|
||||
* Clean up unit tests, enable various disabled tests, make results more useful.
|
||||
|
||||
* Additional cleanup due to static analysis tool results (CppCheck, Flawfinder, Clang analyzer).
|
||||
|
||||
* OST now includes optional iconv support when configured with --enable-iconv.
|
||||
When enabled, binary database & report files store paths as UTF-16, making these files more
|
||||
|
@ -29,11 +39,6 @@ specifying a build directory outside the source dir now works as expected.
|
|||
* Assorted platform tweaks: Add DOS/FreeDOS + DJGPP as a new platform; support Cygwin
|
||||
//host/share/path syntax for UNC paths; passphrase & tempfile fixes for AROS.
|
||||
|
||||
|
||||
======================================
|
||||
|
||||
What was new in earlier 2.4.3 versions:
|
||||
|
||||
* This update fixes compilation errors on modern compilers (GCC 4.7+ and LLVM/clang),
|
||||
as well as some additional errors encountered on various platforms. This is intended
|
||||
to supersede patches against 2.4.2.x, e.g. http://www.linuxfromscratch.org/blfs/view/svn/postlfs/tripwire.html
|
||||
|
@ -66,15 +71,22 @@ defined incorrectly otherwise.
|
|||
The update has been tested on a variety of platforms:
|
||||
|
||||
Linuxes
|
||||
- CentOS 7 (amd64) + gcc 4.8.5
|
||||
- Ubuntu 14.0.4 (amd64) + gcc 4.x
|
||||
- RHEL 3.4 (Itanium) + gcc 3.4.3
|
||||
- Alpine Linux 3.3.3 + gcc 5.3.0
|
||||
- Android 6.0 (arm) + gcc 4.9
|
||||
- Raspbian 7 (wheezy) (armv6l) + gcc 4.6.3
|
||||
- openSuSE Tumbleweed (20160408) (i586) + gcc 5.3.1
|
||||
- RHEL 6.0 (powerpc64) + gcc 4.4.4
|
||||
- Alpine Linux 3.5.1 + gcc 6.2.1
|
||||
- Arch Linux 232 + gcc 6.3.1
|
||||
- Amazon Linux AMI 2016.09 + gcc 4.8.3
|
||||
- Android 6.0 (arm) + gcc 4.9 (NDK)
|
||||
- CentOS 7 (amd64) + gcc 4.8.5
|
||||
- Fedora 24 Alpha 7 (amd64) + gcc 6.0.0
|
||||
- Fedora 27 Rawhide (amd64) + gcc 7.0.1
|
||||
- Raspbian 7 (wheezy) (armv6l) + gcc 4.6.3
|
||||
- RHEL 3.4 (Itanium) + gcc 3.4.3
|
||||
- RHEL 6.0 (powerpc64) + gcc 4.4.4
|
||||
- openSuSE Tumbleweed (20160408) (i586) + gcc 5.3.1
|
||||
- Oracle Linux 6.8 + gcc 4.4.7
|
||||
- Ubuntu 14.0.4 (amd64) + gcc 4.x
|
||||
- Ubuntu 16.0.4 (amd64) + gcc 5.4.0
|
||||
- Wind River Pulsar Linux 8 + gcc 5.2.0
|
||||
|
||||
OSX
|
||||
- Mac OS X 10.11 + LLVM 7.0.2 / clang-700.1.81
|
||||
|
@ -90,7 +102,7 @@ BSDs
|
|||
UNIXes
|
||||
- Solaris 10 SPARC + gcc 3.4.6
|
||||
- Solaris 10 x86 + gcc 3.4.3
|
||||
- OpenIndiana 151 + gcc 4.8.5 [an OpenSolaris/illumos distro]
|
||||
- OpenIndiana 151 + gcc 4.8.5
|
||||
- AIX 5.2 + gcc 4.3.1
|
||||
- HP-UX 11.23 + gcc 4.2.3
|
||||
|
||||
|
|
|
@ -3462,13 +3462,6 @@ fi
|
|||
|
||||
ac_config_headers="$ac_config_headers config.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
rm -f src/tripwire/syslog.h 2> /dev/null
|
||||
chmod 755 install-sh 2> /dev/null
|
||||
|
||||
CFLAGS=${CFLAGS:-"-O -pipe -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
|
||||
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
|
||||
|
||||
|
|
|
@ -11,12 +11,6 @@ AM_CONFIG_HEADER(config.h)
|
|||
AC_COPYRIGHT([The developer of the original code and/or files is Tripwire, Inc. Portions created by Tripwire, Inc. are copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights reserved.])
|
||||
AC_REVISION([$Revision: 2.4.3.5 $])
|
||||
|
||||
dnl #################################
|
||||
dnl Cleanup Cruft Leftover From Patch
|
||||
dnl #################################
|
||||
rm -f src/tripwire/syslog.h 2> /dev/null
|
||||
chmod 755 install-sh 2> /dev/null
|
||||
|
||||
dnl ###############
|
||||
dnl Setup defaults
|
||||
dnl ###############
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
## from Larry Wall's metaconfig.
|
||||
##-------------------------------------------------------
|
||||
|
||||
PATH='.:/bin:/usr/bin'
|
||||
PATH=".:/bin:/usr/bin:/usr/local/bin:$PATH"
|
||||
export PATH || (echo 'You must use sh to run this script'; kill $$)
|
||||
if [ ! -t 0 ] ; then
|
||||
echo "Say 'sh install.sh', not 'sh < install.sh'"
|
||||
|
@ -42,18 +42,6 @@ else
|
|||
c=""
|
||||
fi
|
||||
|
||||
##-------------------------------------------------------
|
||||
## Better have a copy of tar!
|
||||
## If /bin/sh does not exist or is not readable (seems
|
||||
## fairly unlikely), then this will fail.
|
||||
##-------------------------------------------------------
|
||||
|
||||
(tar cvf /dev/null /bin/sh) 2> /dev/null 1>&2
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "tar command not found -- aborting install."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
##-------------------------------------------------------
|
||||
## Can't live without sed.
|
||||
##-------------------------------------------------------
|
||||
|
@ -78,52 +66,24 @@ for p in $awknames; do
|
|||
fi
|
||||
done
|
||||
|
||||
##-------------------------------------------------------
|
||||
## Does this system have a copy of grep we can use?
|
||||
## Some greps don't return status (amazing, huh?),
|
||||
## so we look for a copy of grep that
|
||||
## returns 0 status for an exact match
|
||||
## returns 0 status for a case-insensitive match
|
||||
## returns 0 status for a wildcard match
|
||||
## returns non-zero status for a failed match
|
||||
##-------------------------------------------------------
|
||||
|
||||
GREP=""
|
||||
grepnames="grep egrep"
|
||||
lcgrepstr="findensiemich" # all lower case
|
||||
mcgrepstr="FindenSieMich" # mixed case
|
||||
wcgrepstr="sie.ich$" # wild card match
|
||||
nogrepstr="WoBistDu" # should not be able to find this
|
||||
for p in $grepnames; do
|
||||
(echo "$lcgrepstr" | $p "$lcgrepstr") 2> /dev/null 1>&2
|
||||
if [ $? -eq 0 ]; then
|
||||
(echo "$lcgrepstr" | $p -i "$mcgrepstr") 2> /dev/null 1>&2
|
||||
if [ $? -eq 0 ]; then
|
||||
(echo "$lcgrepstr" | $p "$wcgrepstr") 2> /dev/null 1>&2
|
||||
if [ $? -eq 0 ]; then
|
||||
(echo "$lcgrepstr" | $p "$nogrepstr") 2> /dev/null 1>&2
|
||||
if [ $? -ne 0 ]; then
|
||||
GREP=$p
|
||||
break
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
##-------------------------------------------------------
|
||||
## Does this system have a pager that we can use?
|
||||
## Use cat if desperate.
|
||||
##-------------------------------------------------------
|
||||
|
||||
MORE="cat"
|
||||
morenames="more less cat"
|
||||
morenames="less more most pg cat"
|
||||
for p in $morenames; do
|
||||
($p $0 < /dev/null) 2> /dev/null 1>&2
|
||||
if [ $? -eq 0 ]; then
|
||||
MORE=$p
|
||||
break
|
||||
fi
|
||||
pagerpath=`command -v $p`
|
||||
|
||||
if [ -z $pagerpath ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -x $pagerpath ]; then
|
||||
MORE=$pagerpath
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
##-------------------------------------------------------
|
||||
|
@ -416,15 +376,21 @@ else
|
|||
##-------------------------------------------------------
|
||||
## Verify that the specified editor program exists
|
||||
##-------------------------------------------------------
|
||||
|
||||
TWEDITOR=${TWEDITOR:-'/bin/vi'}
|
||||
|
||||
DEFAULTEDITOR=${EDITOR:-‘/bin/vi’}
|
||||
TWEDITOR=${TWEDITOR:-$DEFAULTEDITOR}
|
||||
TWEDITOR_PATH=`command -v $TWEDITOR`
|
||||
|
||||
if [ -n ${TWEDITOR_PATH} ]; then
|
||||
TWEDITOR=$TWEDITOR_PATH
|
||||
fi
|
||||
|
||||
if [ -x ${TWEDITOR} ]; then
|
||||
echo "${TWEDITOR} exists. Continuing installation."
|
||||
echo
|
||||
echo "${TWEDITOR} exists. Continuing installation."
|
||||
echo
|
||||
else
|
||||
echo "${TWEDITOR} does not exist. Exiting."
|
||||
exit 1
|
||||
echo "${TWEDITOR} not found. Continuing, but your configuration may need to be edited after installation."
|
||||
echo
|
||||
fi
|
||||
|
||||
##-------------------------------------------------------
|
||||
|
@ -927,7 +893,7 @@ cat << END_OF_TEXT
|
|||
----------------------------------------------
|
||||
The installation succeeded.
|
||||
|
||||
Please refer to $README_LOC
|
||||
Please refer to documentation in $TWDOCS
|
||||
for release information and to the printed user documentation
|
||||
for further instructions on using Tripwire 2.4 Open Source.
|
||||
|
||||
|
|
|
@ -403,7 +403,6 @@ char *env;
|
|||
* just include it from the current environment
|
||||
* (if not defined there, don't define it here)
|
||||
*/
|
||||
size_t p_size=0;
|
||||
if (strchr(env, '=') == NULL) {
|
||||
|
||||
q = getenv(env);
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
#define OS OS_OPENBSD
|
||||
#define IS_OPENBSD 1
|
||||
|
||||
#elif defined(_OSX)
|
||||
#elif defined(__APPLE__)
|
||||
#define OS OS_DARWIN
|
||||
#define IS_DARWIN 1
|
||||
|
||||
|
@ -157,7 +157,7 @@
|
|||
#define IS_MIDNIGHTBSD 1
|
||||
|
||||
|
||||
#elif defined(_SOLARIS) || defined(__sun)
|
||||
#elif defined(__sun)
|
||||
#define OS OS_SOLARIS
|
||||
#define IS_SOLARIS 1
|
||||
|
||||
|
@ -165,11 +165,11 @@
|
|||
#define OS OS_AIX
|
||||
#define IS_AIX 1
|
||||
|
||||
#elif defined (_HPUX)
|
||||
#elif defined (__hpux)
|
||||
#define OS OS_HPUX
|
||||
#define IS_HPUX 1
|
||||
|
||||
#elif defined(_IRIX)
|
||||
#elif defined(__sgi)
|
||||
#define OS OS_IRIX
|
||||
#define IS_IRIX 1
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void TestBlockFile()
|
|||
|
||||
try
|
||||
{
|
||||
static const TCHAR fileName[] = _T("c:/tmp/test.bf");
|
||||
static const TCHAR fileName[] = _T("test.bf");
|
||||
// truncate the file I am going to use...
|
||||
//
|
||||
cFileArchive a;
|
||||
|
@ -113,6 +113,7 @@ void TestBlockFile()
|
|||
}
|
||||
catch( eError& e )
|
||||
{
|
||||
TCERR << "Exception: " << e.GetMsg() << std::endl;
|
||||
d.TraceError( _T("Exception caught: %d %s\n"), e.GetID(), e.GetMsg().c_str() );
|
||||
TEST( false );
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void TestBlockRecordArray()
|
|||
cDebug d( "TestBlockRecordArray" );
|
||||
try
|
||||
{
|
||||
static const TCHAR fileName[] = _T("c:/tmp/test.bf");
|
||||
static const TCHAR fileName[] = _T("test.bf");
|
||||
|
||||
cBlockFile bf;
|
||||
bf.Open( fileName, 2, true ); // opened up with two pages
|
||||
|
|
|
@ -88,6 +88,7 @@ const TCHAR* argv5[] =
|
|||
_T("frog")
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
static void PrintCmdLine(int argc, const TCHAR** argv, cDebug d)
|
||||
{
|
||||
TSTRING str;
|
||||
|
@ -99,6 +100,7 @@ static void PrintCmdLine(int argc, const TCHAR** argv, cDebug d)
|
|||
}
|
||||
d.TraceDebug(_T(">>>%s\n"), str.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
static void test_parse(cCmdLineParser& parser, const int argc, const TCHAR** argv, bool should_throw)
|
||||
{
|
||||
|
|
|
@ -142,7 +142,7 @@ size_t DistanceToOne( size_t n )
|
|||
n = ( n >> 1 );
|
||||
}
|
||||
|
||||
ASSERT( n == 1 ); // n was not a power of 2!
|
||||
TEST( n == 1 ); // n was not a power of 2!
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
@ -159,14 +159,14 @@ void ConvertAndCompareString( const std::string& s )
|
|||
wc16_string ws;
|
||||
ws.resize( s.length() );
|
||||
nWrote = iCodeConverter::GetInstance()->Convert( (ntdbs_t)ws.c_str(), ws.length(), s.c_str(), ws.length() );
|
||||
ASSERT( nWrote != -1 );
|
||||
TEST( nWrote != -1 );
|
||||
ws.resize( nWrote );
|
||||
|
||||
// convert back to mbchar_t string
|
||||
std::string s2;
|
||||
s2.resize( ws.length() * MB_CUR_MAX );
|
||||
nWrote = iCodeConverter::GetInstance()->Convert( (ntmbs_t)s2.c_str(), s2.length(), ws.c_str(), ws.length() );
|
||||
ASSERT( nWrote != -1 );
|
||||
TEST( nWrote != -1 );
|
||||
s2.resize( nWrote );
|
||||
|
||||
std::cout << "* Result : ";
|
||||
|
@ -195,10 +195,10 @@ void TestMbToDb()
|
|||
for( size_t j = 0; j < 0x10; j++ )
|
||||
{
|
||||
size_t first_byte = ( i & 0xFF00 ) >> 8;
|
||||
ASSERT( first_byte <= 0xFF );
|
||||
TEST( first_byte <= 0xFF );
|
||||
|
||||
size_t second_byte = ( ( i & 0x00F0 ) >> 4 ) | j;
|
||||
ASSERT( second_byte <= 0xFF );
|
||||
TEST( second_byte <= 0xFF );
|
||||
|
||||
s[ 2 * j ] = NonZeroChar( (char)first_byte );
|
||||
s[ ( 2 * j ) + 1 ] = NonZeroChar( (char)second_byte );
|
||||
|
@ -221,10 +221,10 @@ void TestMbToDb()
|
|||
for( size_t j = 0; j < CHARS_AT_A_TIME; j++ )
|
||||
{
|
||||
size_t first_byte = ( ( i & FIRST_BYTE_MASK ) >> DistanceToOne( CHARS_AT_A_TIME ) );
|
||||
ASSERT( first_byte <= 0xFF );
|
||||
TEST( first_byte <= 0xFF );
|
||||
|
||||
size_t second_byte = ( ( i & ( SECOND_BYTE_MASK << DistanceToOne( CHARS_AT_A_TIME ) ) | j );
|
||||
ASSERT( second_byte <= 0xFF );
|
||||
TEST( second_byte <= 0xFF );
|
||||
|
||||
s[ 2 * j ] = NonZeroChar( (char)first_byte );
|
||||
s[ ( 2 * j ) + 1 ] = NonZeroChar( (char)second_byte );
|
||||
|
|
|
@ -128,11 +128,11 @@ void TestCrypto()
|
|||
cRSAPublicKey* pPublic2;
|
||||
cRSAPrivateKey* pPrivate2;
|
||||
|
||||
ASSERT(pPublic->GetWriteLen() < BUFSIZE);
|
||||
TEST(pPublic->GetWriteLen() < BUFSIZE);
|
||||
pPublic->Write(buf);
|
||||
pPublic2 = new cRSAPublicKey(buf);
|
||||
|
||||
ASSERT(pPrivate->GetWriteLen() < BUFSIZE);
|
||||
TEST(pPrivate->GetWriteLen() < BUFSIZE);
|
||||
pPrivate->Write(buf);
|
||||
pPrivate2 = new cRSAPrivateKey(buf);
|
||||
|
||||
|
@ -298,11 +298,11 @@ void TestCrypto()
|
|||
cElGamalSigPublicKey* pPublic2;
|
||||
cElGamalSigPrivateKey* pPrivate2;
|
||||
|
||||
ASSERT(pPublic->GetWriteLen() < BUFSIZE);
|
||||
TEST(pPublic->GetWriteLen() < BUFSIZE);
|
||||
pPublic->Write(buf);
|
||||
pPublic2 = new cElGamalSigPublicKey(buf);
|
||||
|
||||
ASSERT(pPrivate->GetWriteLen() < BUFSIZE);
|
||||
TEST(pPrivate->GetWriteLen() < BUFSIZE);
|
||||
pPrivate->Write(buf);
|
||||
pPrivate2 = new cElGamalSigPrivateKey(buf);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ static void util_TestUnprintable( const TSTRING& strCUnprintable )
|
|||
TSTRING strOut = strEncoded;
|
||||
e.Decode( strOut );
|
||||
|
||||
ASSERT( strOut == strCUnprintable );
|
||||
TEST( strOut == strCUnprintable );
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,8 +186,8 @@ void TestUnconvertable()
|
|||
ch = 0x ## n; \
|
||||
str = ch; \
|
||||
e.Encode( str ); \
|
||||
// ct.tolower( str.begin(), str.end() ); \
|
||||
ASSERT( str == _T("\\x") _T( #n ) _T("x") );
|
||||
ct.tolower( str.begin(), str.end() ); \
|
||||
TEST( str == _T("\\x") _T( #n ) _T("x") );
|
||||
|
||||
TSS_UNCONVERTABLE_TEST( fefe );
|
||||
TSS_UNCONVERTABLE_TEST( 1234 );
|
||||
|
@ -215,8 +215,8 @@ void TestUnprintable()
|
|||
ch = 0x ## n; \
|
||||
str = ch; \
|
||||
e.Encode( str ); \
|
||||
// ct.tolower( str.begin(), str.end() ); \
|
||||
ASSERT( str == _T("\\x") _T( #n ) _T("x") );
|
||||
ct.tolower( str.begin(), str.end() ); \
|
||||
TEST( str == _T("\\x") _T( #n ) _T("x") );
|
||||
|
||||
TSS_UNPRINTABLE_TEST( 000a );
|
||||
TSS_UNPRINTABLE_TEST( 000d );
|
||||
|
@ -233,11 +233,11 @@ void TestQuoteAndBackSlash()
|
|||
|
||||
str = _T("\\");
|
||||
e.Encode( str );
|
||||
ASSERT( str == _T("\\\\") );
|
||||
TEST( str == _T("\\\\") );
|
||||
|
||||
str = _T("\"");
|
||||
e.Encode( str );
|
||||
ASSERT( str == _T("\\\"") );
|
||||
TEST( str == _T("\\\"") );
|
||||
}
|
||||
|
||||
// TODO:BAM -- try multibyte now.....
|
||||
|
@ -325,7 +325,7 @@ void TestDisplayEncoderBasic()
|
|||
catch( eError& e )
|
||||
{
|
||||
cErrorReporter::PrintErrorMsg( e );
|
||||
ASSERT(false);
|
||||
TEST(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ void TestFCOCompare()
|
|||
cFSDataSourceIter ds2;
|
||||
ds2.SeekToFCO(cFCOName(FILE_NAME), false);
|
||||
iFCO* pFCO2 = ds2.CreateFCO();
|
||||
ASSERT(pFCO2);
|
||||
TEST(pFCO2);
|
||||
pFCO2->AcceptVisitor(&propCalc);
|
||||
d.TraceDebug("Second FCO's properties:\n");
|
||||
PrintProps(pFCO2);
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
|
||||
void TestFCODatabaseFile()
|
||||
{
|
||||
|
||||
//TODO - actually test something here
|
||||
}
|
||||
|
|
|
@ -114,6 +114,8 @@ static bool init (cFCOPropVector &testV)
|
|||
return true;
|
||||
} //end init
|
||||
|
||||
|
||||
#if 0 // TODO: rework this so it doesn't need user interaction
|
||||
static bool addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d)
|
||||
{
|
||||
int var1 = 0 , var2 = 64, var3 = 2;
|
||||
|
@ -191,6 +193,7 @@ static bool addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d)
|
|||
out &= local; //and-ing of results.
|
||||
return out;
|
||||
}//end addRemove
|
||||
#endif
|
||||
|
||||
static bool objManip (cFCOPropVector &testV, cDebug& d)
|
||||
{
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "core/errorbucketimpl.h"
|
||||
#include "fco/fcospecattr.h"
|
||||
#include "fco/fcospechelper.h"
|
||||
#include "fs/fs.h"
|
||||
#include <ctime>
|
||||
|
||||
// we use this instead of TraceContents() so we can test the report iterators.
|
||||
|
@ -62,7 +63,7 @@ static void TraceReport(const cFCOReport& r, cDebug& d)
|
|||
for(specIter.SeekBegin(); ! specIter.Done(); specIter.Next(), ++specCount)
|
||||
{
|
||||
d.TraceDebug(">>> Spec [%d]:\n", specCount);
|
||||
ASSERT(specIter.GetSpec());
|
||||
TEST(specIter.GetSpec());
|
||||
specIter.GetSpec()->TraceContents();
|
||||
specIter.GetAttr()->TraceContents();
|
||||
specIter.GetErrorQueue()->TraceContents();
|
||||
|
@ -88,86 +89,97 @@ static void TraceReport(const cFCOReport& r, cDebug& d)
|
|||
}
|
||||
}
|
||||
|
||||
//TODO: This doesn't actually TEST() anything right now, & will only fail if something throws
|
||||
|
||||
void TestFCOReport()
|
||||
{
|
||||
cDebug d("TestFCOReport");
|
||||
|
||||
|
||||
cFCOSpecImpl* pSpec = new cFCOSpecImpl(_T("/etc"), NULL, new cFCOSpecStopPointSet);
|
||||
cFCOSpecAttr* pAttr = new cFCOSpecAttr;
|
||||
cFSObject* addedFCO = new cFSObject(cFCOName(_T("/etc/added_file")));
|
||||
cFSObject* removedFCO = new cFSObject(cFCOName(_T("/etc/removed_file")));
|
||||
cFSObject* changedFCO = new cFSObject(cFCOName(_T("/etc/changed_file")));
|
||||
cFSObject* oldChangedFCO = new cFSObject(cFCOName(_T("/etc/changed_file")));
|
||||
cFSObject* newChangedFCO = new cFSObject(cFCOName(_T("/etc/changed_file")));
|
||||
cFCOPropVector changedPropVector;
|
||||
|
||||
//Calculate the time taken to generate the test report:
|
||||
time_t* dummy_arg = NULL;
|
||||
time_t time_finish;
|
||||
//time_t time_begin = time(dummy_arg);
|
||||
|
||||
try
|
||||
{
|
||||
cFCOReport report;
|
||||
cFCOSpecImpl* pSpec = new cFCOSpecImpl(_T("/etc"), NULL, new cFCOSpecStopPointSet);
|
||||
cFCOSpecAttr* pAttr = new cFCOSpecAttr;
|
||||
cFSObject* addedFCO = new cFSObject(cFCOName(_T("/etc/added_file")));
|
||||
cFSObject* removedFCO = new cFSObject(cFCOName(_T("/etc/removed_file")));
|
||||
cFSObject* changedFCO = new cFSObject(cFCOName(_T("/etc/changed_file")));
|
||||
cFSObject* oldChangedFCO = new cFSObject(cFCOName(_T("/etc/changed_file")));
|
||||
cFSObject* newChangedFCO = new cFSObject(cFCOName(_T("/etc/changed_file")));
|
||||
cFCOPropVector changedPropVector;
|
||||
|
||||
changedPropVector.AddItem(cFSPropSet::PROP_SIZE);
|
||||
pSpec->SetStartPoint(cFCOName(_T("/etc")));
|
||||
pAttr->SetName(_T("/etc"));
|
||||
pAttr->SetSeverity(53);
|
||||
//Calculate the time taken to generate the test report:
|
||||
time_t* dummy_arg = NULL;
|
||||
time_t time_finish;
|
||||
//time_t time_begin = time(dummy_arg);
|
||||
|
||||
report.AddSpec(0x00020001, pSpec, pAttr); // TODO:bam - change these
|
||||
cFCOReportSpecIter it(report, 0x00020001); // to use cFS::Genre
|
||||
it.GetAddedSet()->Insert(addedFCO);
|
||||
it.GetRemovedSet()->Insert(removedFCO);
|
||||
report.AddChangedFCO(it, oldChangedFCO, newChangedFCO, changedPropVector);
|
||||
|
||||
//Store the time taken to generate the test report:
|
||||
time_finish = time(dummy_arg);
|
||||
//report.SetCreationTime( (int64)difftime(time_finish, time_begin));
|
||||
//d.TraceDebug("Report calculation time = %I64i seconds.\n", report.GetCreationTime());
|
||||
|
||||
d.TraceDebug("Before serializing report:\n");
|
||||
TraceReport(report, d);
|
||||
{
|
||||
cFileArchive outFile;
|
||||
outFile.OpenReadWrite(_T("tmp.twr"));
|
||||
cSerializerImpl outSer(outFile, cSerializerImpl::S_WRITE);
|
||||
cFCOReport report;
|
||||
|
||||
outSer.Init();
|
||||
outSer.WriteObject(&report);
|
||||
outSer.Finit();
|
||||
changedPropVector.AddItem(cFSPropSet::PROP_SIZE);
|
||||
pSpec->SetStartPoint(cFCOName(_T("/etc")));
|
||||
pAttr->SetName(_T("/etc"));
|
||||
pAttr->SetSeverity(53);
|
||||
|
||||
outFile.Close();
|
||||
report.AddSpec(cFS::GenreID(), pSpec, pAttr);
|
||||
cFCOReportSpecIter it(report, cFS::GenreID());
|
||||
it.GetAddedSet()->Insert(addedFCO);
|
||||
it.GetRemovedSet()->Insert(removedFCO);
|
||||
report.AddChangedFCO(it, oldChangedFCO, newChangedFCO, changedPropVector);
|
||||
|
||||
cFileArchive inFile;
|
||||
inFile.OpenRead(_T("tmp.twr"));
|
||||
cSerializerImpl inSer(inFile, cSerializerImpl::S_READ);
|
||||
//Store the time taken to generate the test report:
|
||||
time_finish = time(dummy_arg);
|
||||
//report.SetCreationTime( (int64)difftime(time_finish, time_begin));
|
||||
//d.TraceDebug("Report calculation time = %I64i seconds.\n", report.GetCreationTime());
|
||||
|
||||
cFCOReport inReport;
|
||||
d.TraceDebug("Before serializing report:\n");
|
||||
TraceReport(report, d);
|
||||
{
|
||||
cFileArchive outFile;
|
||||
outFile.OpenReadWrite(_T("tmp.twr"));
|
||||
cSerializerImpl outSer(outFile, cSerializerImpl::S_WRITE);
|
||||
|
||||
inSer.Init();
|
||||
inSer.ReadObject(&inReport);
|
||||
inSer.Finit();
|
||||
outSer.Init();
|
||||
outSer.WriteObject(&report);
|
||||
outSer.Finit();
|
||||
|
||||
d.TraceDebug("Read in serialized report:\n");
|
||||
TraceReport(inReport, d);
|
||||
outFile.Close();
|
||||
|
||||
cFileArchive inFile;
|
||||
inFile.OpenRead(_T("tmp.twr"));
|
||||
cSerializerImpl inSer(inFile, cSerializerImpl::S_READ);
|
||||
|
||||
cFCOReport inReport;
|
||||
|
||||
inSer.Init();
|
||||
inSer.ReadObject(&inReport);
|
||||
inSer.Finit();
|
||||
|
||||
d.TraceDebug("Read in serialized report:\n");
|
||||
TraceReport(inReport, d);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO -- test cFCOReportSpecIter::Remove()
|
||||
// TODO -- test cFCOReportChangeIter::Remove()
|
||||
d.TraceDebug("*** We still need to test Remove() for the two iterator classes!\n");
|
||||
|
||||
pSpec->Release();
|
||||
pAttr->Release();
|
||||
addedFCO->Release();
|
||||
removedFCO->Release();
|
||||
changedFCO->Release();
|
||||
oldChangedFCO->Release();
|
||||
newChangedFCO->Release();
|
||||
|
||||
}
|
||||
|
||||
// TODO -- test cFCOReportSpecIter::Remove()
|
||||
// TODO -- test cFCOReportChangeIter::Remove()
|
||||
d.TraceDebug("*** We still need to test Remove() for the two iterator classes!\n");
|
||||
|
||||
pSpec->Release();
|
||||
pAttr->Release();
|
||||
addedFCO->Release();
|
||||
removedFCO->Release();
|
||||
changedFCO->Release();
|
||||
oldChangedFCO->Release();
|
||||
newChangedFCO->Release();
|
||||
|
||||
catch(const eError& e)
|
||||
{
|
||||
TCERR << std::endl << e.GetMsg() << std::endl;
|
||||
TEST(false);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
TEST(false);
|
||||
}
|
||||
|
||||
d.TraceDebug("Leaving...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "twtest/test.h"
|
||||
#include "core/archive.h"
|
||||
#include "core/serializerimpl.h"
|
||||
#include "twtest/test.h"
|
||||
|
||||
static void TraceSpecAttr(const cFCOSpecAttr* pAttr, cDebug d)
|
||||
{
|
||||
|
@ -50,39 +51,52 @@ static void TraceSpecAttr(const cFCOSpecAttr* pAttr, cDebug d)
|
|||
}
|
||||
}
|
||||
|
||||
//TODO: This doesn't actually TEST() anything right now, & will only fail if something throws
|
||||
|
||||
void TestFCOSpecAttr()
|
||||
{
|
||||
cDebug d("TestFCOSpecAttr");
|
||||
d.TraceDebug("Entering\n");
|
||||
cFCOSpecAttr* pAttr = new cFCOSpecAttr;
|
||||
|
||||
try
|
||||
{
|
||||
d.TraceDebug("Entering\n");
|
||||
cFCOSpecAttr* pAttr = new cFCOSpecAttr;
|
||||
|
||||
pAttr->SetName (_T("My Name")); d.TraceDebug("Setting Name = My Name\n");
|
||||
pAttr->SetSeverity (53); d.TraceDebug("Setting Severity = 53\n");
|
||||
pAttr->AddEmail (_T("dog@bark.com")); d.TraceDebug("Adding email = dog@bark.com\n");
|
||||
pAttr->AddEmail (_T("cow@moo.com")); d.TraceDebug("Adding email = cow@moo.com\n");
|
||||
pAttr->AddEmail (_T("cat@meow.com")); d.TraceDebug("Adding email = cat@meow.com\n");
|
||||
pAttr->SetName (_T("My Name")); d.TraceDebug("Setting Name = My Name\n");
|
||||
pAttr->SetSeverity (53); d.TraceDebug("Setting Severity = 53\n");
|
||||
pAttr->AddEmail (_T("dog@bark.com")); d.TraceDebug("Adding email = dog@bark.com\n");
|
||||
pAttr->AddEmail (_T("cow@moo.com")); d.TraceDebug("Adding email = cow@moo.com\n");
|
||||
pAttr->AddEmail (_T("cat@meow.com")); d.TraceDebug("Adding email = cat@meow.com\n");
|
||||
|
||||
// trace contents...
|
||||
TraceSpecAttr(pAttr, d);
|
||||
// trace contents...
|
||||
TraceSpecAttr(pAttr, d);
|
||||
|
||||
// test serialization...
|
||||
d.TraceDebug("Testing Serialization; next output should be the same as the previous\n");
|
||||
cMemoryArchive a;
|
||||
cSerializerImpl s(a, cSerializerImpl::S_WRITE);
|
||||
s.Init();
|
||||
pAttr->Write(&s);
|
||||
s.Finit();
|
||||
a.Seek(0, cBidirArchive::BEGINNING);
|
||||
cFCOSpecAttr* pNew = new cFCOSpecAttr;
|
||||
cSerializerImpl s2(a, cSerializerImpl::S_READ);
|
||||
s2.Init();
|
||||
pNew->Read(&s2);
|
||||
s2.Finit();
|
||||
// test serialization...
|
||||
d.TraceDebug("Testing Serialization; next output should be the same as the previous\n");
|
||||
cMemoryArchive a;
|
||||
cSerializerImpl s(a, cSerializerImpl::S_WRITE);
|
||||
s.Init();
|
||||
pAttr->Write(&s);
|
||||
s.Finit();
|
||||
a.Seek(0, cBidirArchive::BEGINNING);
|
||||
cFCOSpecAttr* pNew = new cFCOSpecAttr;
|
||||
cSerializerImpl s2(a, cSerializerImpl::S_READ);
|
||||
s2.Init();
|
||||
pNew->Read(&s2);
|
||||
s2.Finit();
|
||||
|
||||
// trace contents...
|
||||
TraceSpecAttr(pNew, d);
|
||||
// trace contents...
|
||||
TraceSpecAttr(pNew, d);
|
||||
|
||||
pNew->Release();
|
||||
pAttr->Release();
|
||||
pNew->Release();
|
||||
pAttr->Release();
|
||||
}
|
||||
catch(const eError& e)
|
||||
{
|
||||
TCERR << std::endl << e.GetMsg() << std::endl;
|
||||
TEST(false);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
TEST(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,44 +37,57 @@
|
|||
#include "twtest/test.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//TODO: This doesn't actually TEST() anything right now, & will only fail if something throws
|
||||
void TestFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
TSTRING fileName = TEMP_DIR;
|
||||
fileName += _T("/file_test.bin");
|
||||
|
||||
TSTRING fileName = TEMP_DIR;
|
||||
fileName += _T("/file_test.bin");
|
||||
//Create a temporary file for testing:
|
||||
FILE* testStream;
|
||||
testStream = _tfopen( fileName.c_str(), _T("w+b"));
|
||||
TEST(testStream);
|
||||
|
||||
TSTRING testString( _T("This is a test") );
|
||||
int iTestStringLength = testString.length();
|
||||
|
||||
//Create a temporary file for testing:
|
||||
FILE* testStream;
|
||||
testStream = _tfopen( fileName.c_str(), _T("w+b"));
|
||||
TSTRING testString( _T("This is a test") );
|
||||
int iTestStringLength = testString.length();
|
||||
//Write some data to the stream...
|
||||
fwrite( testString.c_str(), sizeof(TCHAR), iTestStringLength, testStream );
|
||||
fclose( testStream );
|
||||
|
||||
//Write some data to the stream...
|
||||
fwrite( testString.c_str(), sizeof(TCHAR), iTestStringLength, testStream );
|
||||
fclose( testStream );
|
||||
//Open the file again, for reading only this time.
|
||||
testStream = _tfopen( fileName.c_str(), _T("rb") );
|
||||
TEST(testStream);
|
||||
|
||||
cFile fTempFile;
|
||||
//Try attaching one of our file objects to the stream.
|
||||
//TODO: fTempFile.AttachRead( testStream );
|
||||
|
||||
//Open the file again, for reading only this time.
|
||||
testStream = _tfopen( fileName.c_str(), _T("rb") );
|
||||
//Try reading something from the file object
|
||||
TCHAR buffer[40];
|
||||
TCHAR buffer2[40];
|
||||
|
||||
cFile fTempFile;
|
||||
//Try attaching one of our file objects to the stream.
|
||||
//TODO: fTempFile.AttachRead( testStream );
|
||||
fTempFile.Read( buffer, sizeof(TCHAR) * iTestStringLength );
|
||||
fTempFile.Close();
|
||||
|
||||
//Try reading something from the file object
|
||||
TCHAR buffer[40];
|
||||
TCHAR buffer2[40];
|
||||
|
||||
fTempFile.Read( buffer, sizeof(TCHAR) * iTestStringLength );
|
||||
fTempFile.Close();
|
||||
|
||||
testStream = _tfopen( fileName.c_str(), _T("a+b") );
|
||||
//TODO: fTempFile.AttachReadWrite( testStream );
|
||||
|
||||
//Now try writing something to the stream.
|
||||
fTempFile.Write( testString.c_str(), sizeof(TCHAR) * iTestStringLength );
|
||||
fTempFile.Rewind();
|
||||
fTempFile.Read( buffer2, sizeof(TCHAR) * iTestStringLength * 2 );
|
||||
testStream = _tfopen( fileName.c_str(), _T("a+b") );
|
||||
TEST(testStream);
|
||||
//TODO: fTempFile.AttachReadWrite( testStream );
|
||||
|
||||
//Now try writing something to the stream.
|
||||
fTempFile.Write( testString.c_str(), sizeof(TCHAR) * iTestStringLength );
|
||||
fTempFile.Rewind();
|
||||
fTempFile.Read( buffer2, sizeof(TCHAR) * iTestStringLength * 2 );
|
||||
}
|
||||
catch(const eError& e)
|
||||
{
|
||||
TCERR << std::endl << e.GetMsg() << std::endl;
|
||||
TEST(false);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
TEST(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void TestFSPropCalc()
|
|||
// get the fco but none of its children...
|
||||
ds.SeekToFCO(cFCOName(foo_bin), false);
|
||||
iFCO* pFCO = ds.CreateFCO();
|
||||
ASSERT(pFCO);
|
||||
TEST(pFCO);
|
||||
|
||||
// create the calculator and set some properties to calculate...
|
||||
cFSPropCalc propCalc;
|
||||
|
|
|
@ -34,13 +34,14 @@
|
|||
#include "fco/stdfco.h"
|
||||
#include "fco/fcospecimpl.h"
|
||||
#include "core/debug.h"
|
||||
//#include "fs/fsdatasource.h"
|
||||
#include "fs/fsdatasourceiter.h"
|
||||
#include "fco/iterproxy.h"
|
||||
#include "core/error.h"
|
||||
#include "twtest/test.h"
|
||||
#include "fco/fcospechelper.h"
|
||||
#include "core/fsservices.h"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PrintFCOTree -- recursively prints an fco's name and all of it's children's
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -69,43 +70,35 @@ void TestFCOSpecImpl()
|
|||
cDebug d("TestFCOSpecImpl");
|
||||
d.TraceDebug("Entering...\n");
|
||||
|
||||
//*********************
|
||||
//
|
||||
// TODO -- As of tripwire 2.1, this needs to be updated!
|
||||
// 28 Jan 99 mdb
|
||||
//
|
||||
//*********************
|
||||
ASSERT( false );
|
||||
/*
|
||||
cFSDataSource dataSrc;
|
||||
iFSServices* pFSS = iFSServices::GetInstance();
|
||||
|
||||
cFSDataSourceIter dataSrc;
|
||||
|
||||
// test AllChildStopPoint fcos...
|
||||
d.TraceDebug("Now testing a spec whose start point is the only thing it maps to (%s)\n", TEMP_DIR);
|
||||
cFCOSpecImpl* pSpec2 = new cFCOSpecImpl(TEMP_DIR, &dataSrc, new cFCOSpecNoChildren);
|
||||
pSpec2->SetStartPoint(cFCOName(TEMP_DIR));
|
||||
iFCO* pFCO = pSpec2->CreateFCO(pSpec2->GetStartPoint(), iFCODataSource::CHILDREN_ALL);
|
||||
PrintFCOTree(pFCO, d, 0);
|
||||
dataSrc.SeekToFCO(pSpec2->GetStartPoint(), false);
|
||||
iFCO* pFCO = dataSrc.CreateFCO();
|
||||
TEST(pFCO);
|
||||
//PrintFCOTree(pFCO, d, 0);
|
||||
pFCO->Release();
|
||||
|
||||
// create an FSSpec and set up some start and stop points...
|
||||
cFCOSpecStopPointSet* pSet = new cFCOSpecStopPointSet;
|
||||
cFCOSpecImpl* pSpec = new cFCOSpecImpl(_T("Test FSSpec"), &dataSrc, pSet);
|
||||
pSpec->SetStartPoint(cFCOName(_T("d:/code")));
|
||||
pSet->Add(cFCOName(_T("d:/code/open gl")));
|
||||
pSet->Add(cFCOName(_T("d:/code/pclient")));
|
||||
pSpec->SetStartPoint(cFCOName(_T("/etc")));
|
||||
pSet->Add(cFCOName(_T("/etc/open gl")));
|
||||
pSet->Add(cFCOName(_T("/etc/pclient")));
|
||||
|
||||
// create all the fcos...
|
||||
pFCO = pSpec->CreateFCO(pSpec->GetStartPoint(), iFCODataSource::CHILDREN_ALL);
|
||||
ASSERT(pFCO);
|
||||
PrintFCOTree(pFCO, d, 0);
|
||||
pFCO->Release();
|
||||
cFSDataSourceIter dataSrc2;
|
||||
dataSrc2.SeekToFCO(pSpec->GetStartPoint(), false);
|
||||
iFCO* pFCO2 = dataSrc2.CreateFCO();
|
||||
TEST(pFCO2);
|
||||
//PrintFCOTree(pFCO, d, 0);
|
||||
pFCO2->Release();
|
||||
|
||||
// TODO -- test Clone(), copy ctor, operator=
|
||||
|
||||
pSpec->Release();
|
||||
return;
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -36,38 +36,26 @@
|
|||
#include "fco/stdfco.h"
|
||||
#include "fco/genreswitcher.h"
|
||||
#include "twtest/test.h"
|
||||
#include "fs/fs.h"
|
||||
|
||||
#ifdef _CPPRTTI
|
||||
#include "fs/fsfactory.h"
|
||||
#include "ntfs/ntfsfactory.h"
|
||||
#endif
|
||||
|
||||
void TestGenreSwitcher()
|
||||
{
|
||||
#pragma message( __FILE__ "(1) : TODO - implement this test file")
|
||||
#if 0
|
||||
cDebug d("TestGenreSwitcher");
|
||||
d.TraceDebug("Entering...\n");
|
||||
|
||||
// normally we use the cGenreSwitcher::GetInstance() interface
|
||||
// to get access the class singleton. But for testing purposes
|
||||
// we will put have one reside on the stack.
|
||||
cGenreSwitcher genreSwitcher;
|
||||
cGenreSwitcher* genreSwitcher = cGenreSwitcher::GetInstance();
|
||||
|
||||
TEST(genreSwitcher.CurrentGenre() == cGenre::GENRE_INVALID);
|
||||
TEST(genreSwitcher->CurrentGenre() == cFS::GenreID());
|
||||
|
||||
// can't switch to invalid genre
|
||||
//genreSwitcher->SelectGenre(cGenre::GENRE_INVALID);
|
||||
//TEST(genreSwitcher->CurrentGenre() == cGenre::GENRE_INVALID);
|
||||
|
||||
genreSwitcher.SelectGenre(cGenre::FS);
|
||||
TEST(genreSwitcher.CurrentGenre() == cGenre::FS);
|
||||
#ifdef _CPPRTTI
|
||||
genreSwitcher->SelectGenre(cFS::GenreID());
|
||||
TEST(genreSwitcher->CurrentGenre() == cFS::GenreID());
|
||||
TEST(typeid(*iTWFactory::GetInstance()) == typeid(cFSFactory));
|
||||
#endif
|
||||
|
||||
genreSwitcher.SelectGenre(cGenre::NTFS);
|
||||
TEST(genreSwitcher.CurrentGenre() == cGenre::NTFS);
|
||||
#ifdef _CPPRTTI
|
||||
TEST(typeid(*iTWFactory::GetInstance()) == typeid(cNTFSFactory));
|
||||
#endif
|
||||
|
||||
d.TraceDebug("All tests passed.\n");
|
||||
#endif //#if 0
|
||||
}
|
||||
|
|
|
@ -73,12 +73,15 @@ static void GetNoun( TSTRING& noun )
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
void TestHierDatabaseInteractive()
|
||||
{
|
||||
TCERR << std::endl << "TestHierDatabaseInteractive needs to be redesigned (& renamed) to not require user interaction" << std::endl;
|
||||
|
||||
#if 0
|
||||
cDebug d( "TestHierDatabaseInteractive" );
|
||||
try
|
||||
{
|
||||
cHierDatabase db;
|
||||
//db.Open( _T("c:/tmp/tw.hdb"), 5, true);
|
||||
db.Open( _T("c:/tmp/tw.db"), 5, false);
|
||||
db.Open( _T("tw.db"), 5, false);
|
||||
cHierDatabase::iterator iter(&db);
|
||||
|
||||
while( true )
|
||||
|
@ -346,5 +349,5 @@ void TestHierDatabaseInteractive()
|
|||
d.TraceError( "Exception caught: %d %s\n", e.GetID(), e.GetMsg().c_str() );
|
||||
TEST( false );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ void TestKeyFile()
|
|||
{
|
||||
cElGamalSig elGamal(*keyfile.GetPublicKey());
|
||||
|
||||
ASSERT(elGamal.GetBlockSizePlain() < 9000);
|
||||
ASSERT(elGamal.GetBlockSizeCipher() < 9000);
|
||||
TEST(elGamal.GetBlockSizePlain() < 9000);
|
||||
TEST(elGamal.GetBlockSizeCipher() < 9000);
|
||||
std::string s = "haybaby";
|
||||
cPrivateKeyProxy key;
|
||||
TEST(key.AquireKey(keyfile, (int8*)s.data(), 7));
|
||||
|
|
|
@ -203,15 +203,15 @@ void TestAlignment()
|
|||
void TestSizes()
|
||||
{
|
||||
/*
|
||||
ASSERT( CanBeRepresentedAs( char(), char() ) );
|
||||
ASSERT( CanBeRepresentedAs( char(), unsigned char() ) );
|
||||
ASSERT( CanBeRepresentedAs( unsigned char(), char() ) );
|
||||
ASSERT( CanBeRepresentedAs( unsigned char(), unsigned char() ) );
|
||||
ASSERT( CanBeRepresentedAs( signed char(), char() ) );
|
||||
ASSERT( CanBeRepresentedAs( char(), signed char() ) );
|
||||
ASSERT( CanBeRepresentedAs( signed char(), signed char() ) );
|
||||
ASSERT( CanBeRepresentedAs( signed char(), unsigned char() ) );
|
||||
ASSERT( CanBeRepresentedAs( char(), signed char() ) );
|
||||
TEST( CanBeRepresentedAs( char(), char() ) );
|
||||
TEST( CanBeRepresentedAs( char(), unsigned char() ) );
|
||||
TEST( CanBeRepresentedAs( unsigned char(), char() ) );
|
||||
TEST( CanBeRepresentedAs( unsigned char(), unsigned char() ) );
|
||||
TEST( CanBeRepresentedAs( signed char(), char() ) );
|
||||
TEST( CanBeRepresentedAs( char(), signed char() ) );
|
||||
TEST( CanBeRepresentedAs( signed char(), signed char() ) );
|
||||
TEST( CanBeRepresentedAs( signed char(), unsigned char() ) );
|
||||
TEST( CanBeRepresentedAs( char(), signed char() ) );
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ void TestRefCountObj()
|
|||
|
||||
db.TraceAlways("Entering...\n");
|
||||
|
||||
// Note the following test of Reference counted objects containing
|
||||
// Note the following test of Reference counted objects containing
|
||||
// copies of themselves failed. Perhaps someday we will upgrade the
|
||||
// reference counting interface to allow this type of structure.
|
||||
/*
|
||||
|
@ -157,11 +157,12 @@ void TestRefCountObj()
|
|||
}
|
||||
}
|
||||
|
||||
//These fields only exist in debug builds, so we can't use TEST() here.
|
||||
ASSERT(cRefCountObj::objectCounter == 0);
|
||||
ASSERT(cRefCountObj::referenceCounter == 0);
|
||||
|
||||
db.TraceAlways("Done...\n");
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,13 +71,11 @@ void TestFCOSpec();
|
|||
void TestFCOPropVector();
|
||||
void TestFileHeader();
|
||||
void TestFSPropSet();
|
||||
void TestFSDataSource();
|
||||
void TestFCOSpecImpl();
|
||||
void TestFSPropCalc();
|
||||
void TestFCOPropImpl();
|
||||
void TestFCOCompare();
|
||||
//void TestTripwire();
|
||||
void TestFCOSetUtil();
|
||||
void TestWin32FSServices();
|
||||
void TestFCOSpecList();
|
||||
void TestFCOReport();
|
||||
|
@ -88,7 +86,6 @@ void TestRefCountObj();
|
|||
void TestSignature();
|
||||
void TestSerRefCountObj();
|
||||
void TestUnixFSServices();
|
||||
//void TestFCODatabase();
|
||||
void TestError();
|
||||
void TestDebug();
|
||||
void TestFcoSpecUtil();
|
||||
|
@ -96,7 +93,7 @@ void TestTypes();
|
|||
void TestTCHAR();
|
||||
void TestErrorBucketImpl();
|
||||
void TestHashTable();
|
||||
//void TestTextReportViewer();
|
||||
void TestTextReportViewer();
|
||||
void TestFCONameTbl();
|
||||
void TestConfigFile();
|
||||
|
||||
|
@ -108,16 +105,14 @@ void TestCryptoArchive();
|
|||
void TestFCOSpecAttr();
|
||||
void TestCmdLineParser();
|
||||
void TestTaskTimer();
|
||||
//void TestObjectPool();
|
||||
void TestKeyFile();
|
||||
void TestFCOSetCached();
|
||||
void TestTWUtil();
|
||||
void TestFSPropDisplayer();
|
||||
void TestFSPropDisplayer();
|
||||
void TestGenre();
|
||||
void TestFSDataSourceIter();
|
||||
void TestGenerateDb();
|
||||
//void TestHierDatabaseInteractive();
|
||||
void TestHierDatabaseInteractive();
|
||||
void TestGenreSwitcher();
|
||||
void TestDbDataSource();
|
||||
void TestGenreSpecList();
|
||||
|
@ -125,12 +120,11 @@ void TestIntegrityCheck();
|
|||
void TestFCODatabaseFile();
|
||||
void TestWchar16();
|
||||
void TestStringEncoder();
|
||||
//void TestDisplayEncoder();
|
||||
|
||||
void TestGrowHeap();
|
||||
void TestPlatform();
|
||||
//void TestBlockFile();
|
||||
//void TestBlockRecordArray();
|
||||
//void TestHierDatabaseInteractive();
|
||||
void TestBlockFile();
|
||||
void TestBlockRecordArray();
|
||||
void TestTWLocale();
|
||||
void TestFileUtil();
|
||||
void TestFCONameTranslator();
|
||||
|
@ -158,92 +152,114 @@ void Usage()
|
|||
_T("(runs test id's 1, 2, 3, and 12)\n\n");
|
||||
}
|
||||
|
||||
const int MAX_TEST_ID = 100;
|
||||
const int MAX_TEST_ID = 88;
|
||||
|
||||
static int failed_count = 0;
|
||||
|
||||
static void Test(int testID)
|
||||
{
|
||||
switch (testID)
|
||||
{
|
||||
case 1: TestArchive(); break;
|
||||
case 2: TestCmdLineParser(); break;
|
||||
case 3: TestCrypto(); break;
|
||||
case 4: TestCryptoArchive(); break;
|
||||
case 5: TestDebug(); break;
|
||||
case 6: TestError(); break;
|
||||
case 7: TestErrorBucketImpl(); break;
|
||||
case 8: TestFCOCompare(); break;
|
||||
//case 9: TestFCODatabase(); break;
|
||||
//case 11: TestFCOErrorQueue(); break;
|
||||
case 12: TestFCOName(); break;
|
||||
case 13: TestFCONameTbl(); break;
|
||||
case 14: TestFCOPropVector(); break;
|
||||
case 15: TestFCOPropImpl(); break;
|
||||
case 16: TestFCOReport(); break;
|
||||
//case 17: TestFCOSetCached(); break;
|
||||
case 18: TestFCOSetImpl(); break;
|
||||
//case 19: TestFCOSetUtil(); break;
|
||||
case 20: TestFCOSpecAttr(); break;
|
||||
case 21: TestFCOSpecHelper(); break;
|
||||
case 22: TestFCOSpecList(); break;
|
||||
case 23: TestFcoSpecUtil(); break;
|
||||
case 24: TestFileHeader(); break;
|
||||
//case 25: TestFSDataSource(); break;
|
||||
case 26: TestFSPropSet(); break;
|
||||
case 27: TestFSPropCalc(); break;
|
||||
case 28: TestFCOSpecImpl(); break;
|
||||
case 29: TestHashTable(); break;
|
||||
// case 30: TestObjectPool(); break;
|
||||
case 31: TestRefCountObj(); break;
|
||||
case 32: TestSerializerImpl(); break;
|
||||
case 33: TestSerRefCountObj(); break;
|
||||
case 34: TestSignature(); break;
|
||||
case 35: TestTaskTimer(); break;
|
||||
//case 36: TestTripwire(); break;
|
||||
//case 37: TestTextReportViewer(); break;
|
||||
case 39: TestSerRefCountObj(); break;
|
||||
case 40: TestError(); break;
|
||||
//case 41: TestFCODatabase(); break;
|
||||
case 42: TestHashTable(); break;
|
||||
case 43: TestTCHAR(); break;
|
||||
case 44: TestUnixFSServices(); break;
|
||||
case 46: TestConfigFile(); break;
|
||||
case 47: TestPolicyParser(); break;
|
||||
case 48: TestKeyFile(); break;
|
||||
case 49: TestTWUtil(); break;
|
||||
case 50: TestFSPropDisplayer(); break;
|
||||
case 52: TestGenre(); break;
|
||||
case 53: TestFSDataSourceIter(); break;
|
||||
//case 54: TestGenerateDb(); break;
|
||||
//case 55: TestHierDatabaseInteractive(); break;
|
||||
case 56: TestGenreSwitcher(); break;
|
||||
case 57: TestDbDataSource(); break;
|
||||
case 58: TestGenreSpecList(); break;
|
||||
//case 59: TestIntegrityCheck(); break;
|
||||
case 65: TestWchar16(); break;
|
||||
case 66: TestStringEncoder(); break;
|
||||
//case 67: TestDisplayEncoder(); break;
|
||||
case 69: TestGrowHeap(); break;
|
||||
case 70: TestPlatform(); break;
|
||||
//case 71: TestBlockFile(); break;
|
||||
//case 72: TestBlockRecordArray(); break;
|
||||
//case 73: TestHierDatabaseInteractive(); break;
|
||||
case 74: TestFileUtil(); break;
|
||||
case 75: TestTWLocale(); break;
|
||||
case 76: TestFCONameTranslator(); break;
|
||||
case 77: TestStringUtil(); break;
|
||||
case 78: TestCodeConverter(); break;
|
||||
|
||||
case 79: TestCharToHex(); break;
|
||||
case 80: TestHexToChar(); break;
|
||||
case 81: TestStringToHex(); break;
|
||||
case 82: TestHexToString(); break;
|
||||
// case 83: TestUnconvertable(); break;
|
||||
// case 84: TestUnprintable(); break;
|
||||
case 85: TestQuoteAndBackSlash(); break;
|
||||
case 86: TestDisplayEncoderBasic(); break;
|
||||
case 87: TestCharUtilBasic(); break;
|
||||
case 88: TestConfigFile2(); break;
|
||||
TCERR << std::endl << "=== Running test ID #" << testID << " ===" << std::endl;
|
||||
|
||||
try {
|
||||
|
||||
switch (testID)
|
||||
{
|
||||
case 1: TestArchive(); break;
|
||||
case 2: TestCmdLineParser(); break;
|
||||
case 3: TestCrypto(); break;
|
||||
case 4: TestCryptoArchive(); break;
|
||||
case 5: TestDebug(); break;
|
||||
case 6: TestError(); break;
|
||||
case 7: TestErrorBucketImpl(); break;
|
||||
case 8: TestFCOCompare(); break;
|
||||
|
||||
case 12: TestFCOName(); break;
|
||||
case 13: TestFCONameTbl(); break;
|
||||
case 14: TestFCOPropVector(); break;
|
||||
case 15: TestFCOPropImpl(); break;
|
||||
case 16: TestFCOReport(); break;
|
||||
|
||||
case 18: TestFCOSetImpl(); break;
|
||||
|
||||
case 20: TestFCOSpecAttr(); break;
|
||||
case 21: TestFCOSpecHelper(); break;
|
||||
case 22: TestFCOSpecList(); break;
|
||||
case 23: TestFcoSpecUtil(); break;
|
||||
case 24: TestFileHeader(); break;
|
||||
|
||||
case 26: TestFSPropSet(); break;
|
||||
case 27: TestFSPropCalc(); break;
|
||||
case 28: TestFCOSpecImpl(); break;
|
||||
case 29: TestHashTable(); break;
|
||||
|
||||
case 31: TestRefCountObj(); break;
|
||||
case 32: TestSerializerImpl(); break;
|
||||
case 33: TestSerRefCountObj(); break;
|
||||
case 34: TestSignature(); break;
|
||||
case 35: TestTaskTimer(); break;
|
||||
//case 36: TestTripwire(); break;
|
||||
case 37: TestTextReportViewer(); break;
|
||||
case 39: TestSerRefCountObj(); break;
|
||||
case 40: TestError(); break;
|
||||
case 41: TestFCODatabaseFile(); break;
|
||||
case 42: TestHashTable(); break;
|
||||
case 43: TestTCHAR(); break;
|
||||
case 44: TestUnixFSServices(); break;
|
||||
case 46: TestConfigFile(); break;
|
||||
case 47: TestPolicyParser(); break;
|
||||
case 48: TestKeyFile(); break;
|
||||
case 49: TestTWUtil(); break;
|
||||
case 50: TestFSPropDisplayer(); break;
|
||||
case 52: TestGenre(); break;
|
||||
case 53: TestFSDataSourceIter(); break;
|
||||
//case 54: TestGenerateDb(); break;
|
||||
case 55: TestHierDatabaseInteractive(); break;
|
||||
case 56: TestGenreSwitcher(); break;
|
||||
case 57: TestDbDataSource(); break;
|
||||
case 58: TestGenreSpecList(); break;
|
||||
//case 59: TestIntegrityCheck(); break;
|
||||
|
||||
case 65: TestWchar16(); break;
|
||||
case 66: TestStringEncoder(); break;
|
||||
|
||||
case 69: TestGrowHeap(); break;
|
||||
case 70: TestPlatform(); break;
|
||||
case 71: TestBlockFile(); break;
|
||||
case 72: TestBlockRecordArray(); break;
|
||||
case 74: TestFileUtil(); break;
|
||||
case 75: TestTWLocale(); break;
|
||||
case 76: TestFCONameTranslator(); break;
|
||||
case 77: TestStringUtil(); break;
|
||||
case 78: TestCodeConverter(); break;
|
||||
|
||||
case 79: TestCharToHex(); break;
|
||||
case 80: TestHexToChar(); break;
|
||||
case 81: TestStringToHex(); break;
|
||||
case 82: TestHexToString(); break;
|
||||
// case 83: TestUnconvertable(); break;
|
||||
// case 84: TestUnprintable(); break;
|
||||
case 85: TestQuoteAndBackSlash(); break;
|
||||
case 86: TestDisplayEncoderBasic(); break;
|
||||
case 87: TestCharUtilBasic(); break;
|
||||
case 88: TestConfigFile2(); break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (eError& error)
|
||||
{
|
||||
cTWUtil::PrintErrorMsg(error);
|
||||
failed_count++;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
TCERR << "FAILED: " << e.what() << std::endl;
|
||||
failed_count++;
|
||||
}
|
||||
catch (...) {
|
||||
TCERR << "FAILED: <unknown>" << std::endl;
|
||||
failed_count++;
|
||||
}
|
||||
|
||||
TCERR << std::endl << "=== test ID #" << testID << " completed ===" << std::endl;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -336,9 +352,9 @@ int _tmain(int argc, TCHAR** argv)
|
|||
|
||||
// force user to hit <CR>
|
||||
|
||||
std::cout << std::endl << "Tests completed" << std::endl;
|
||||
|
||||
return 0;
|
||||
std::cout << std::endl << "Tests completed with " << failed_count << " failures." << std::endl;
|
||||
|
||||
return failed_count ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -69,7 +71,7 @@ TSS_EndPackage( cTest )
|
|||
#define TEST(exp) if (!(exp)) \
|
||||
{ \
|
||||
std::cerr<<"TEST(" << #exp << ") failure, file " << __FILE__ << " line " << __LINE__ << std::endl; \
|
||||
exit(-1); \
|
||||
throw std::runtime_error(#exp); \
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "tw/stdtw.h"
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tw/fcoreport.h"
|
||||
#include "fco/fcospecimpl.h"
|
||||
|
@ -56,7 +57,7 @@
|
|||
#include "tw/fcoreportutil.h"
|
||||
#include "tw/headerinfo.h"
|
||||
|
||||
#ifdef FIXED_TRV_TEST_SUITE
|
||||
//#ifdef FIXED_TRV_TEST_SUITE
|
||||
|
||||
void MakeFile( TSTRING& fcoNameMakeMe );
|
||||
void MakeDir( const TCHAR* const lpszDirName );
|
||||
|
@ -80,7 +81,7 @@ static void TraceReport(const cFCOReport& r, cDebug& d)
|
|||
for(specIter.SeekBegin(); ! specIter.Done(); specIter.Next(), ct++)
|
||||
{
|
||||
d.TraceDebug(">>> Spec [%d]:\n", ct);
|
||||
ASSERT(specIter.GetSpec());
|
||||
TEST(specIter.GetSpec());
|
||||
specIter.GetSpec()->TraceContents();
|
||||
specIter.GetErrorQueue()->TraceContents();
|
||||
|
||||
|
@ -105,8 +106,30 @@ static void TraceReport(const cFCOReport& r, cDebug& d)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//
|
||||
// basic functionality
|
||||
//
|
||||
void DisplayReportAndHaveUserUpdateIt( const TSTRING& edName, ReportingLevel level = FULL_REPORT ); //throw (eFSServices, eTextReportViewer, eInternal);
|
||||
// outputs the given report to a temp file, opens an editor, has
|
||||
// the user view changes to the database, and, by selecting FCO entries,
|
||||
// chooses which changes to write to the database. Unchecked entries
|
||||
// are removed from the report
|
||||
// edName is the name of the editor to use to update the report
|
||||
|
||||
virtual void PrintTextReport( const TSTRING& strFilename, ReportingLevel level = FULL_REPORT ); //throw (eTextReportViewer);
|
||||
// if strFilename is "-", will print to TCOUT
|
||||
virtual void PrintTextReport( TOSTREAM& ostr, ReportingLevel level = FULL_REPORT ); //throw (eTextReportViewer);
|
||||
// prints the report to the specified ostream
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void TestTextReportViewer()
|
||||
{
|
||||
TCERR << std::endl << "TestTextReportViewer needs to be cleaned up & fixed, currently disabled" << std::endl;
|
||||
|
||||
#if 0
|
||||
cFCOReport report;
|
||||
cFCOReportGenreIter genreIter(report);
|
||||
cFCOReportSpecIter specIter(genreIter);
|
||||
|
@ -119,7 +142,7 @@ void TestTextReportViewer()
|
|||
try
|
||||
{
|
||||
iFSServices* pFSServices = iFSServices::GetInstance();
|
||||
ASSERT( pFSServices );
|
||||
TEST( pFSServices );
|
||||
|
||||
TSTRING fcoNameTempDir;
|
||||
pFSServices->GetTempDirName( fcoNameTempDir );
|
||||
|
@ -127,9 +150,9 @@ void TestTextReportViewer()
|
|||
fcoNameSpec1 = fcoNameTempDir += _T("SPEC1/");
|
||||
fcoNameSpec2 = fcoNameTempDir += _T("SPEC2/");
|
||||
|
||||
pFSServices->Mkdir( fcoNameTempDir );
|
||||
pFSServices->Mkdir( fcoNameSpec1.AsString() );
|
||||
pFSServices->Mkdir( fcoNameSpec2.AsString() );
|
||||
mkdir( fcoNameTempDir.c_str(), 0777 );
|
||||
mkdir( fcoNameSpec1.AsString().c_str(), 0777 );
|
||||
mkdir( fcoNameSpec2.AsString().c_str(), 0777 );
|
||||
|
||||
fcoNameTempFile = fcoNameTempDir += _T("twtempXXXXXX");
|
||||
pFSServices->MakeTempFilename( fcoNameTempFile );
|
||||
|
@ -137,12 +160,12 @@ void TestTextReportViewer()
|
|||
catch(eFSServices& /* e */)
|
||||
{
|
||||
// TODO: properly handle error
|
||||
ASSERT( false );
|
||||
TEST( false );
|
||||
}
|
||||
|
||||
|
||||
// need two prop calcs because.....
|
||||
// if cFSPropCalc::VisitFSObject succeeds, cFSPropCalc stores the FCO in
|
||||
// an internal set (why, I don't know), and the cFCOSet ASSERTs that the same
|
||||
// an internal set (why, I don't know), and the cFCOSet TESTs that the same
|
||||
// FCO isn't inserted more than once. But since we visit changed FCOs twice
|
||||
// in this test routine, we need two calcs. Make sense? Oh, well.
|
||||
cFSPropCalc* pPropCalc = new cFSPropCalc;
|
||||
|
@ -153,7 +176,7 @@ void TestTextReportViewer()
|
|||
cFCOSpecImpl* pSpec = new cFCOSpecImpl( fcoNameSpec1.AsString(), NULL, pStopPts);
|
||||
cFCOSpecAttr* pAttr = new cFCOSpecAttr;
|
||||
|
||||
|
||||
|
||||
cFCOPropVector v;
|
||||
for( int i = 0; i < 32; i++ )
|
||||
v.AddItem( i );
|
||||
|
@ -161,7 +184,6 @@ void TestTextReportViewer()
|
|||
pPropCalc->SetPropVector(v);
|
||||
pPropCalc2->SetPropVector(v);
|
||||
|
||||
|
||||
TSTRING fcoNameMakeMe;
|
||||
fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/added_fileXXXXXX");
|
||||
MakeFile( fcoNameMakeMe );
|
||||
|
@ -172,9 +194,10 @@ void TestTextReportViewer()
|
|||
// MakeTempFile can't handle strings with escaped quotes, so we'll have to do this ourselves
|
||||
fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/\"quoted\\_and_backslashed_file1\"");
|
||||
//TOFSTREAM file1( fcoNameMakeMe.c_str() );
|
||||
//ASSERT( file1 );
|
||||
//TEST( file1 );
|
||||
//file1.close();
|
||||
|
||||
|
||||
cFSObject* addedFCO2 = new cFSObject( cFCOName(fcoNameMakeMe) );
|
||||
//pPropCalc->VisitFSObject( *addedFCO2 );
|
||||
|
||||
|
@ -182,7 +205,7 @@ void TestTextReportViewer()
|
|||
// MakeTempFile can't handle strings with escaped quotes, so we'll have to do this ourselves
|
||||
fcoNameMakeMe = fcoNameSpec1.AsString() + _T("/quoted_file\"2\"XXXXXX");
|
||||
//TOFSTREAM file2( fcoNameMakeMe.c_str() );
|
||||
//ASSERT( file2 );
|
||||
//TEST( file2 );
|
||||
//file2.close();
|
||||
|
||||
cFSObject* addedFCO3 = new cFSObject( cFCOName(fcoNameMakeMe) );
|
||||
|
@ -199,6 +222,7 @@ void TestTextReportViewer()
|
|||
MakeFile( fcoNameMakeMe );
|
||||
cFSObject* removedFCO2 = new cFSObject( cFCOName(fcoNameMakeMe) );
|
||||
pPropCalc->VisitFSObject( *removedFCO2 );
|
||||
|
||||
|
||||
pSpec->SetStartPoint( fcoNameSpec1 );
|
||||
pAttr->SetName( fcoNameSpec1.AsString() );
|
||||
|
@ -207,7 +231,9 @@ void TestTextReportViewer()
|
|||
report.AddSpec(0x00020001, pSpec, pAttr, &specIter); // TODO:bam - use cFS::Genre
|
||||
pAttr->Release();
|
||||
|
||||
|
||||
TEST(specIter.GetAddedSet());
|
||||
TEST(specIter.GetRemovedSet());
|
||||
|
||||
specIter.GetAddedSet()->Insert(addedFCO);
|
||||
specIter.GetAddedSet()->Insert(addedFCO2);
|
||||
specIter.GetAddedSet()->Insert(addedFCO3);
|
||||
|
@ -234,6 +260,7 @@ void TestTextReportViewer()
|
|||
changedPropVector1.AddItem(cFSPropSet::PROP_UID);
|
||||
report.AddChangedFCO(specIter, oldChangedFCO, newChangedFCO, changedPropVector1);
|
||||
|
||||
|
||||
// make changed FCO2
|
||||
cFCOPropVector changedPropVector2;
|
||||
|
||||
|
@ -280,7 +307,7 @@ void TestTextReportViewer()
|
|||
specIter.GetAddedSet()->Insert(addedFCO5);
|
||||
specIter.GetRemovedSet()->Insert(removedFCO5);
|
||||
|
||||
|
||||
|
||||
|
||||
// make changed FCO3
|
||||
cFCOPropVector changedPropVector3;
|
||||
|
@ -321,14 +348,13 @@ void TestTextReportViewer()
|
|||
specIter.Next();
|
||||
//specIter.GetErrorQueue()->AddError(2, "this is an \"/etc2\" spec error",NULL);
|
||||
|
||||
|
||||
d.TraceDebug(_T("\n======================================================\nStart PrintTextReport...\n======================================================\n\n\n"));
|
||||
|
||||
TSTRING tstrEmpty( _T("") );
|
||||
cFCOReportHeader rhi;
|
||||
cFCOReportUtil::FinalizeReport( report );
|
||||
cTextReportViewer trv;
|
||||
trv.DisplayReportAndHaveUserUpdateIt( rhi, report, _T("") );
|
||||
cTextReportViewer trv(rhi, report);
|
||||
trv.DisplayReportAndHaveUserUpdateIt( _T("") );
|
||||
|
||||
// test writing of USID
|
||||
cFileArchive outFile;
|
||||
|
@ -354,20 +380,20 @@ void TestTextReportViewer()
|
|||
|
||||
d.TraceDebug("Read in serialized report:\n");
|
||||
//TraceReport(inReport, d);
|
||||
trv.PrintTextReport( rhi, inReport, TSTRING( TEMP_DIR _T( "/test2.txt" ) ) );
|
||||
trv.PrintTextReport(TSTRING( TEMP_DIR _T( "/test2.txt" ) ) );
|
||||
|
||||
//TODO: this does not work any more
|
||||
//trv.LaunchEditorOnFile( TSTRING( TEMP_DIR _T("/test2.txt") ), _T("") );
|
||||
|
||||
|
||||
// look at results
|
||||
trv.PrintTextReport( rhi, report, fcoNameTempFile );
|
||||
trv.PrintTextReport(fcoNameTempFile );
|
||||
//TODO: this does not work any more
|
||||
//cTextReportViewer::LaunchEditorOnFile( fcoNameTempFile, _T("") );
|
||||
|
||||
|
||||
iFSServices* pFSServices = iFSServices::GetInstance();
|
||||
ASSERT( pFSServices );
|
||||
TEST( pFSServices );
|
||||
pFSServices->FileDelete( addedFCO->GetName().AsString() );
|
||||
pFSServices->FileDelete( addedFCO2->GetName().AsString() );
|
||||
pFSServices->FileDelete( addedFCO3->GetName().AsString() );
|
||||
|
@ -382,8 +408,8 @@ void TestTextReportViewer()
|
|||
pFSServices->FileDelete( fcoNameTempFile );
|
||||
|
||||
// don't remove TEMP_DIR since other people may be using it
|
||||
pFSServices->Rmdir( fcoNameSpec1.AsString() );
|
||||
pFSServices->Rmdir( fcoNameSpec2.AsString() );
|
||||
rmdir( fcoNameSpec1.AsString().c_str() );
|
||||
rmdir( fcoNameSpec2.AsString().c_str() );
|
||||
|
||||
pSpec->Release();
|
||||
pSpec2->Release();
|
||||
|
@ -404,7 +430,8 @@ void TestTextReportViewer()
|
|||
newChangedFCO3->Release();
|
||||
oldChangedFCO4->Release();
|
||||
newChangedFCO4->Release();
|
||||
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -412,50 +439,40 @@ void MakeFile( TSTRING& strNameMakeMe )
|
|||
{
|
||||
try
|
||||
{
|
||||
iFSServices* pFSServices = iFSServices::GetInstance(); ASSERT( pFSServices );
|
||||
iFSServices* pFSServices = iFSServices::GetInstance(); TEST( pFSServices );
|
||||
pFSServices->MakeTempFilename( strNameMakeMe );
|
||||
|
||||
std::string strA;
|
||||
for( TSTRING::iterator i = strNameMakeMe.begin(); i != strNameMakeMe.end(); ++i )
|
||||
{
|
||||
char ach[6];
|
||||
ASSERT( MB_CUR_MAX <= 6 );
|
||||
TEST( MB_CUR_MAX <= 6 );
|
||||
|
||||
int n = wctomb( ach, *i );
|
||||
ASSERT( n != -1 );
|
||||
TEST( n != -1 );
|
||||
|
||||
for( int j = 0; j < n; j++ )
|
||||
strA += ach[j];
|
||||
}
|
||||
|
||||
TOFSTREAM file( strA.c_str() );
|
||||
ASSERT( file );
|
||||
TEST( file );
|
||||
file.close();
|
||||
}
|
||||
catch( eFSServices e )
|
||||
{
|
||||
ASSERT( false );
|
||||
TEST( false );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
ASSERT( false );
|
||||
TEST( false );
|
||||
}
|
||||
}
|
||||
|
||||
void MakeDir( const TCHAR* const lpszDirName )
|
||||
{
|
||||
try
|
||||
{
|
||||
iFSServices* pFSServices = iFSServices::GetInstance();
|
||||
TSTRING newdir(lpszDirName);
|
||||
|
||||
pFSServices->Mkdir( newdir );
|
||||
}
|
||||
catch( eFSServices e )
|
||||
{
|
||||
ASSERT( false );
|
||||
}
|
||||
TEST(0 == mkdir(lpszDirName, 0777 ))
|
||||
}
|
||||
|
||||
#endif //FIXED_TRV_TEST_SUITE
|
||||
//#endif //FIXED_TRV_TEST_SUITE
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void TestHex();
|
|||
try \
|
||||
{ \
|
||||
x; \
|
||||
ASSERT( false ); \
|
||||
TEST( false ); \
|
||||
} catch( error& ) {}
|
||||
|
||||
void TestTWLocale()
|
||||
|
@ -80,21 +80,21 @@ void TestAtoi()
|
|||
//
|
||||
cTWLocale::InitGlobalLocale();
|
||||
n = cTWLocale::FormatNumber( str );
|
||||
ASSERT( n == 123456 );
|
||||
TEST( n == 123456 );
|
||||
|
||||
//
|
||||
// Try formatting with "" locale
|
||||
//
|
||||
std::locale::global( std::locale("") );
|
||||
n = cTWLocale::FormatNumber( str );
|
||||
ASSERT( n == 123456 );
|
||||
TEST( n == 123456 );
|
||||
|
||||
//
|
||||
// Try formatting with "C" locale
|
||||
//
|
||||
std::locale::global( std::locale("") );
|
||||
n = cTWLocale::FormatNumber( str );
|
||||
ASSERT( n == 123456 );
|
||||
TEST( n == 123456 );
|
||||
}
|
||||
|
||||
void TestItoa()
|
||||
|
@ -147,7 +147,7 @@ void TestRoundtrip()
|
|||
strOut = cTWLocale::FormatNumber( cTWLocale::FormatNumber( strIn ), strOut );
|
||||
// don't know if string will be the same due to possible changes in formatting from locale
|
||||
// ASSERT( strOut == strIn ); <---- can't do this ^^^
|
||||
ASSERT( 123456 == cTWLocale::FormatNumber( strOut ) );
|
||||
TEST( 123456 == cTWLocale::FormatNumber( strOut ) );
|
||||
|
||||
|
||||
//
|
||||
|
@ -156,7 +156,7 @@ void TestRoundtrip()
|
|||
int32 nIn = 654321;
|
||||
int32 nOut;
|
||||
nOut = cTWLocale::FormatNumber( cTWLocale::FormatNumber( nIn, strIn ) );
|
||||
ASSERT( nOut == nIn );
|
||||
TEST( nOut == nIn );
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,7 +172,7 @@ void TestFlags()
|
|||
//
|
||||
TSTRING str = _T("FF");
|
||||
int n = cTWLocale::FormatNumber( str, std::ios_base::hex );
|
||||
ASSERT( n == 0xFF );
|
||||
TEST( n == 0xFF );
|
||||
|
||||
//
|
||||
// bad number for dec
|
||||
|
@ -184,21 +184,21 @@ void TestFlags()
|
|||
//
|
||||
TSTRING strOct = _T("0712");
|
||||
n = cTWLocale::FormatNumber( strOct, std::ios_base::oct );
|
||||
ASSERT( n == 0712 );
|
||||
TEST( n == 0712 );
|
||||
|
||||
//
|
||||
// oct again
|
||||
//
|
||||
strOct = _T("00712");
|
||||
n = cTWLocale::FormatNumber( strOct, std::ios_base::oct );
|
||||
ASSERT( n == 0712 );
|
||||
TEST( n == 0712 );
|
||||
|
||||
//
|
||||
// oct again again
|
||||
//
|
||||
strOct = _T("712");
|
||||
n = cTWLocale::FormatNumber( strOct, std::ios_base::oct );
|
||||
ASSERT( n == 0712 );
|
||||
TEST( n == 0712 );
|
||||
|
||||
//
|
||||
// try bad oct
|
||||
|
@ -212,16 +212,16 @@ void TestHex()
|
|||
TSTRING str;
|
||||
|
||||
str = cTWLocale::FormatNumberAsHex( 0x1234 );
|
||||
ASSERT( str == _T("1234") );
|
||||
TEST( str == _T("1234") );
|
||||
|
||||
str = cTWLocale::FormatNumberAsHex( 16 );
|
||||
ASSERT( str == _T("10") );
|
||||
TEST( str == _T("10") );
|
||||
|
||||
str = cTWLocale::FormatNumberAsHex( 0x12344321 );
|
||||
ASSERT( str == _T("12344321") );
|
||||
TEST( str == _T("12344321") );
|
||||
|
||||
str = cTWLocale::FormatNumberAsHex( 0xFFFFFFFF );
|
||||
ASSERT( str == _T("FFFFFFFF") || str == _T("ffffffff") );
|
||||
TEST( str == _T("FFFFFFFF") || str == _T("ffffffff") );
|
||||
}
|
||||
#endif//DOESNTWORK
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "tw/stdtw.h"
|
||||
#include "tw/twutil.h"
|
||||
#include "util/fileutil.h"
|
||||
#include "twtest/test.h"
|
||||
#include <fstream>
|
||||
|
||||
|
@ -45,8 +46,6 @@ std::string WideToNarrow( const TSTRING& strWide );
|
|||
|
||||
void TestTWUtil()
|
||||
{
|
||||
#pragma message( __FILE__ "(1) : TODO - implement this test file")
|
||||
#if 0
|
||||
// TODO: we should test more than the file exists stuff, but that
|
||||
// is all I need to do for right now.
|
||||
cDebug d("TestTWUtil");
|
||||
|
@ -57,7 +56,7 @@ void TestTWUtil()
|
|||
d.TraceAlways("Testing FileExists() and FileWritable()\n");
|
||||
|
||||
// assuming the current dir is writable, this test should succeed
|
||||
TEST(cTWUtil::FileWritable(_T("afilethatdoesnotexist.tmp")) == true);
|
||||
TEST(cFileUtil::FileWritable(_T("afilethatdoesnotexist.tmp")) == true);
|
||||
|
||||
TSTRING tmpDir = TEMP_DIR;
|
||||
tmpDir += _T("/fileexistdir");
|
||||
|
@ -65,43 +64,42 @@ void TestTWUtil()
|
|||
tmpFN += _T("/fileexiststest.tmp");
|
||||
|
||||
// make a subdir in the TEMP_DIR
|
||||
_tmkdir(tmpDir.c_str(), 0700);
|
||||
_tchmod(tmpDir.c_str(), 0700);
|
||||
mkdir(tmpDir.c_str(), 0700);
|
||||
chmod(tmpDir.c_str(), 0700);
|
||||
|
||||
// make sure file is not there
|
||||
_tchmod(tmpFN.c_str(), 0777);
|
||||
_tunlink(tmpFN.c_str());
|
||||
chmod(tmpFN.c_str(), 0777);
|
||||
unlink(tmpFN.c_str());
|
||||
|
||||
// make sure exists tests false, writable is true
|
||||
// and checking writable should not create the file
|
||||
TEST(cTWUtil::FileExists(tmpFN) == false);
|
||||
TEST(cTWUtil::FileWritable(tmpFN) == true)
|
||||
TEST(cTWUtil::FileExists(tmpFN) == false);
|
||||
TEST(cFileUtil::FileExists(tmpFN) == false);
|
||||
TEST(cFileUtil::FileWritable(tmpFN) == true)
|
||||
TEST(cFileUtil::FileExists(tmpFN) == false);
|
||||
|
||||
// make the dir read only and make sure write tests false
|
||||
// windows fails this test, perhaps because I am an administrator?
|
||||
_tchmod(tmpDir.c_str(), 0500);
|
||||
TEST(cTWUtil::FileWritable(tmpFN) == false);
|
||||
_tchmod(tmpDir.c_str(), 0700);
|
||||
chmod(tmpDir.c_str(), 0500);
|
||||
TEST(cFileUtil::FileWritable(tmpFN) == false);
|
||||
chmod(tmpDir.c_str(), 0700);
|
||||
|
||||
// create the file
|
||||
{
|
||||
std::ofstream ostr(WideToNarrow(tmpFN).c_str());
|
||||
ostr << "Hey there.\n";
|
||||
std::ofstream ostr(WideToNarrow(tmpFN).c_str());
|
||||
ostr << "Hey there.\n";
|
||||
}
|
||||
|
||||
// test a read only file
|
||||
_tchmod(tmpFN.c_str(), 0400);
|
||||
TEST(cTWUtil::FileWritable(tmpFN) == false);
|
||||
chmod(tmpFN.c_str(), 0400);
|
||||
TEST(cFileUtil::FileWritable(tmpFN) == false);
|
||||
|
||||
// test a writable file
|
||||
_tchmod(tmpFN.c_str(), 0666);
|
||||
TEST(cTWUtil::FileWritable(tmpFN) == true);
|
||||
chmod(tmpFN.c_str(), 0666);
|
||||
TEST(cFileUtil::FileWritable(tmpFN) == true);
|
||||
|
||||
// delete the test file and dir
|
||||
_tunlink(tmpFN.c_str());
|
||||
_tunlink(tmpDir.c_str());
|
||||
#endif
|
||||
unlink(tmpFN.c_str());
|
||||
unlink(tmpDir.c_str());
|
||||
}
|
||||
|
||||
std::string WideToNarrow( const TSTRING& strWide )
|
||||
|
|
Loading…
Reference in New Issue