summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/backupdiff/testbackupdiff.cpp8
-rw-r--r--test/backupstorefix/testbackupstorefix.cpp10
-rwxr-xr-xtest/common/testcommon.cpp6
-rwxr-xr-xtest/crypto/testcrypto.cpp2
-rwxr-xr-xtest/raidfile/intercept.cpp53
-rwxr-xr-xtest/raidfile/testraidfile.cpp2
6 files changed, 43 insertions, 38 deletions
diff --git a/test/backupdiff/testbackupdiff.cpp b/test/backupdiff/testbackupdiff.cpp
index 5fb10038..7845433c 100755
--- a/test/backupdiff/testbackupdiff.cpp
+++ b/test/backupdiff/testbackupdiff.cpp
@@ -103,9 +103,9 @@ void check_encoded_file(const char *filename, int64_t OtherFileID, int new_block
file_BlockIndexHeader hdr;
TEST_THAT(enc.ReadFullBuffer(&hdr, sizeof(hdr), 0));
TEST_THAT(hdr.mMagicValue == (int32_t)htonl(OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V1));
- TEST_THAT((uint64_t)ntoh64(hdr.mOtherFileID) == (uint64_t)OtherFileID);
+ TEST_THAT((uint64_t)box_ntoh64(hdr.mOtherFileID) == (uint64_t)OtherFileID);
// number of blocks
- int64_t nblocks = ntoh64(hdr.mNumBlocks);
+ int64_t nblocks = box_ntoh64(hdr.mNumBlocks);
TRACE2("Reading index from '%s', has %lld blocks\n", filename, nblocks);
TRACE0("======== ===== ========== ======== ========\n Index Where EncSz/Idx Size WChcksm\n");
// Read them all in
@@ -114,7 +114,7 @@ void check_encoded_file(const char *filename, int64_t OtherFileID, int new_block
{
file_BlockIndexEntry en;
TEST_THAT(enc.ReadFullBuffer(&en, sizeof(en), 0));
- int64_t s = ntoh64(en.mEncodedSize);
+ int64_t s = box_ntoh64(en.mEncodedSize);
if(s > 0)
{
nnew++;
@@ -126,7 +126,7 @@ void check_encoded_file(const char *filename, int64_t OtherFileID, int new_block
TRACE2("%8lld other i=%8lld", b, 0 - s);
}
// Decode the rest
- uint64_t iv = ntoh64(hdr.mEntryIVBase);
+ uint64_t iv = box_ntoh64(hdr.mEntryIVBase);
iv += b;
sBlowfishDecryptBlockEntry.SetIV(&iv);
file_BlockIndexEntryEnc entryEnc;
diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp
index a4edfd31..c36bb8b8 100644
--- a/test/backupstorefix/testbackupstorefix.cpp
+++ b/test/backupstorefix/testbackupstorefix.cpp
@@ -411,11 +411,11 @@ int test(int argc, const char *argv[])
} h;
TEST_THAT(file->Read(&h, sizeof(h)) == sizeof(h));
// Modify
- TEST_THAT(ntoh64(h.hdr.mOtherFileID) == 0);
- TEST_THAT(ntoh64(h.hdr.mNumBlocks) >= 2);
- h.hdr.mOtherFileID = hton64(2345); // don't worry about endianness
- h.e[0].mEncodedSize = hton64((ntoh64(h.e[0].mEncodedSize)) + (ntoh64(h.e[1].mEncodedSize)));
- h.e[1].mOtherBlockIndex = hton64(-2);
+ TEST_THAT(box_ntoh64(h.hdr.mOtherFileID) == 0);
+ TEST_THAT(box_ntoh64(h.hdr.mNumBlocks) >= 2);
+ h.hdr.mOtherFileID = box_hton64(2345); // don't worry about endianness
+ h.e[0].mEncodedSize = box_hton64((box_ntoh64(h.e[0].mEncodedSize)) + (box_ntoh64(h.e[1].mEncodedSize)));
+ h.e[1].mOtherBlockIndex = box_hton64(static_cast<uint64_t>(-2));
// Write to modified file
f.Write(&h, sizeof(h));
// Commit new version
diff --git a/test/common/testcommon.cpp b/test/common/testcommon.cpp
index 7febf92f..546228bc 100755
--- a/test/common/testcommon.cpp
+++ b/test/common/testcommon.cpp
@@ -396,7 +396,7 @@ int test(int argc, const char *argv[])
TEST_THAT(lock1.TryAndGetLock("testfiles/lock1") == true);
// Try to lock something using the same lock
TEST_CHECK_THROWS(lock1.TryAndGetLock("testfiles/non-exist/lock2"), CommonException, NamedLockAlreadyLockingSomething);
-#ifndef PLATFORM_open_USE_fcntl
+#if defined(HAVE_FLOCK) || HAVE_DECL_O_EXLOCK
// And again on that name
NamedLock lock2;
TEST_THAT(lock2.TryAndGetLock("testfiles/lock1") == false);
@@ -484,7 +484,7 @@ int test(int argc, const char *argv[])
TEST_THAT(elist.SizeOfDefiniteList() == 4);
// Add regex entries
- #ifndef PLATFORM_REGEX_NOT_SUPPORTED
+ #ifdef HAVE_REGEX_H
elist.AddRegexEntries(std::string("[a-d]+\\.reg$" "\x01" "EXCLUDE" "\x01" "^exclude$"));
elist.AddRegexEntries(std::string(""));
TEST_CHECK_THROWS(elist.AddRegexEntries(std::string("[:not_valid")), CommonException, BadRegularExpression);
@@ -499,7 +499,7 @@ int test(int argc, const char *argv[])
TEST_THAT(elist.IsExcluded(std::string("ThingDefThree")) == true);
TEST_THAT(elist.IsExcluded(std::string("AnotherDef")) == true);
TEST_THAT(elist.IsExcluded(std::string("dir/DefNumberTwo")) == false);
- #ifndef PLATFORM_REGEX_NOT_SUPPORTED
+ #ifdef HAVE_REGEX_H
TEST_THAT(elist.IsExcluded(std::string("b.reg")) == true);
TEST_THAT(elist.IsExcluded(std::string("e.reg")) == false);
TEST_THAT(elist.IsExcluded(std::string("b.Reg")) == false);
diff --git a/test/crypto/testcrypto.cpp b/test/crypto/testcrypto.cpp
index 983ae57e..c312a4a0 100755
--- a/test/crypto/testcrypto.cpp
+++ b/test/crypto/testcrypto.cpp
@@ -256,7 +256,7 @@ int test(int argc, const char *argv[])
// Cipher type
::printf("Blowfish...\n");
test_cipher<CipherBlowfish, 8>();
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
::printf("AES...\n");
test_cipher<CipherAES, 16>();
#else
diff --git a/test/raidfile/intercept.cpp b/test/raidfile/intercept.cpp
index 60c0ca1e..11cd06e9 100755
--- a/test/raidfile/intercept.cpp
+++ b/test/raidfile/intercept.cpp
@@ -9,7 +9,9 @@
#include "Box.h"
-#include <sys/syscall.h>
+#ifdef HAVE_SYS_SYSCALL_H
+ #include <sys/syscall.h>
+#endif
#include <sys/types.h>
#include <unistd.h>
#include <sys/uio.h>
@@ -17,8 +19,12 @@
#ifndef PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE
-#ifdef PLATFORM_DARWIN
- // For some reason, __syscall just doesn't work on Darwin
+#if !defined(HAVE_SYSCALL) && !defined(HAVE___SYSCALL) && !defined(HAVE___SYSCALL_NEED_DEFN)
+ #define PLATFORM_NO_SYSCALL
+#endif
+
+#ifdef PLATFORM_NO_SYSCALL
+ // For some reason, syscall just doesn't work on Darwin
// so instead, we build functions using assembler in a varient
// of the technique used in the Darwin Libc
extern "C" int
@@ -34,13 +40,14 @@
extern "C" off_t
TEST_lseek(int fildes, off_t offset, int whence);
#else
- #if defined(PLATFORM_LINUX) || defined(PLATFORM_SUNOS)
- #undef __syscall
- #define __syscall syscall
- #else
- // Need this, not declared in syscall.h
+ #ifdef HAVE___SYSCALL_NEED_DEFN
+ // Need this, not declared in syscall.h nor unistd.h
extern "C" off_t __syscall(quad_t number, ...);
#endif
+ #ifndef HAVE_SYSCALL
+ #undef syscall
+ #define syscall __syscall
+ #endif
#endif
#include <string.h>
@@ -137,10 +144,10 @@ open(const char *path, int flags, mode_t mode)
return -1;
}
}
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_open(path, flags, mode);
#else
- int r = __syscall(SYS_open, path, flags, mode);
+ int r = syscall(SYS_open, path, flags, mode);
#endif
if(intercept_enabled && intercept_filedes == -1)
{
@@ -158,10 +165,10 @@ extern "C" int
close(int d)
{
CHECK_FOR_FAKE_ERROR_COND(d, SIZE_ALWAYS_ERROR, SYS_close, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_close(d);
#else
- int r = __syscall(SYS_close, d);
+ int r = syscall(SYS_close, d);
#endif
if(r == 0)
{
@@ -177,10 +184,10 @@ extern "C" ssize_t
write(int d, const void *buf, size_t nbytes)
{
CHECK_FOR_FAKE_ERROR_COND(d, nbytes, SYS_write, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_write(d, buf, nbytes);
#else
- int r = __syscall(SYS_write, d, buf, nbytes);
+ int r = syscall(SYS_write, d, buf, nbytes);
#endif
if(r != -1)
{
@@ -193,10 +200,10 @@ extern "C" ssize_t
read(int d, void *buf, size_t nbytes)
{
CHECK_FOR_FAKE_ERROR_COND(d, nbytes, SYS_read, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_read(d, buf, nbytes);
#else
- int r = __syscall(SYS_read, d, buf, nbytes);
+ int r = syscall(SYS_read, d, buf, nbytes);
#endif
if(r != -1)
{
@@ -216,10 +223,10 @@ readv(int d, const struct iovec *iov, int iovcnt)
}
CHECK_FOR_FAKE_ERROR_COND(d, nbytes, SYS_readv, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_readv(d, iov, iovcnt);
#else
- int r = __syscall(SYS_readv, d, iov, iovcnt);
+ int r = syscall(SYS_readv, d, iov, iovcnt);
#endif
if(r != -1)
{
@@ -233,15 +240,13 @@ lseek(int fildes, off_t offset, int whence)
{
// random magic for lseek syscall, see /usr/src/lib/libc/sys/lseek.c
CHECK_FOR_FAKE_ERROR_COND(fildes, 0, SYS_lseek, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_lseek(fildes, offset, whence);
#else
- #if defined(PLATFORM_LINUX) || defined(PLATFORM_SUNOS)
- off_t r = __syscall(SYS_lseek, fildes, offset, whence);
+ #ifdef HAVE_LSEEK_DUMMY_PARAM
+ off_t r = syscall(SYS_lseek, fildes, 0 /* extra 0 required here! */, offset, whence);
#else
- // Should swap this condition round. No reason to assume that most OS
- // do this syscall wierdness, default should be the sensible way
- off_t r = __syscall(SYS_lseek, fildes, 0 /* extra 0 required here! */, offset, whence);
+ off_t r = syscall(SYS_lseek, fildes, offset, whence);
#endif
#endif
if(r != -1)
diff --git a/test/raidfile/testraidfile.cpp b/test/raidfile/testraidfile.cpp
index 9803d44d..1e510486 100755
--- a/test/raidfile/testraidfile.cpp
+++ b/test/raidfile/testraidfile.cpp
@@ -525,7 +525,7 @@ void test_overwrites()
writeA.Write("TESTTEST", 8);
{
-#ifndef PLATFORM_open_USE_fcntl
+#if defined(HAVE_FLOCK) || HAVE_DECL_O_EXLOCK
RaidFileWrite writeA2(0, "overwrite_A");
TEST_CHECK_THROWS(writeA2.Open(), RaidFileException, FileIsCurrentlyOpenForWriting);
#endif