void testDeleteLsmdb(const char *zFile){ char *zLog = testMallocPrintf("%s-log", zFile); char *zShm = testMallocPrintf("%s-shm", zFile); unlink(zFile); unlink(zLog); unlink(zShm); testFree(zLog); testFree(zShm); }
/* ** File zFile is the path to a database. This function restores ** a backup of the database made by a previous call to testSaveDb(). ** Specifically, it does the equivalent of: ** ** cp $(zFile)-save $(zFile) ** cp $(zFile)-save-$(zAux) $(zFile)-$(zAux) */ void testRestoreDb(const char *zFile, const char *zAux){ char *zLog = testMallocPrintf("%s-%s", zFile, zAux); char *zFileSave = testMallocPrintf("%s-save", zFile); char *zLogSave = testMallocPrintf("%s-%s-save", zFile, zAux); copy_file(zFileSave, zFile); copy_file(zLogSave, zLog); testFree(zLog); testFree(zFileSave); testFree(zLogSave); }
void testCopyLsmdb(const char *zFrom, const char *zTo){ char *zLog1 = testMallocPrintf("%s-log", zFrom); char *zLog2 = testMallocPrintf("%s-log", zTo); char *zShm1 = testMallocPrintf("%s-shm", zFrom); char *zShm2 = testMallocPrintf("%s-shm", zTo); unlink(zShm2); unlink(zLog2); unlink(zTo); copy_file(zFrom, zTo); copy_file(zLog1, zLog2); copy_file(zShm1, zShm2); testFree(zLog1); testFree(zLog2); testFree(zShm1); testFree(zShm2); }
static void copy_file(const char *zFrom, const char *zTo){ if( access(zFrom, F_OK) ){ unlink(zTo); }else{ int fd1; int fd2; off_t sz; off_t i; struct stat buf; u8 *aBuf; fd1 = open(zFrom, O_RDONLY, 0644); fd2 = open(zTo, O_RDWR | O_CREAT, 0644); fstat(fd1, &buf); sz = buf.st_size; ftruncate(fd2, sz); aBuf = testMalloc(4096); for(i=0; i<sz; i+=4096){ int nByte = MIN(4096, sz - i); read(fd1, aBuf, nByte); write(fd2, aBuf, nByte); } testFree(aBuf); close(fd1); close(fd2); } }
int main(int argc, char **argv) { testNew(); testFree(); testInsert(); UnitTest_report(); }
static char *getName4(const char *zSystem, Datatest4 *pTest){ char *zRet; char *zData; zData = testDatasourceName(&pTest->defn); zRet = testMallocPrintf("data4.%s.%s.%d.%d.%d", zSystem, zData, pTest->nRec, pTest->nRepeat, pTest->bReopen ); testFree(zData); return zRet; }
int test_mem(int argc, char *argv[]) { unsigned int *array = NULL; int arraySize = 10; PKIX_UInt32 actualMinorVersion; PKIX_UInt32 j = 0; PKIX_TEST_STD_VARS(); startTests("Memory Allocation"); PKIX_TEST_EXPECT_NO_ERROR( PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext)); subTest("PKIX_PL_Malloc"); testMalloc(&array); subTest("PKIX_PL_Realloc"); testRealloc(&array); subTest("PKIX_PL_Free"); testFree(array); /* --Negative Test Cases------------------- */ /* Create an integer array of size 10 */ PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Malloc( (PKIX_UInt32)(arraySize*sizeof (unsigned int)), (void **) &array, plContext)); (void) printf("Attempting to reallocate 0 sized memory...\n"); PKIX_TEST_EXPECT_NO_ERROR (PKIX_PL_Realloc(array, 0, (void **) &array, plContext)); (void) printf("Attempting to allocate to null pointer...\n"); PKIX_TEST_EXPECT_ERROR(PKIX_PL_Malloc(10, NULL, plContext)); (void) printf("Attempting to reallocate to null pointer...\n"); PKIX_TEST_EXPECT_ERROR(PKIX_PL_Realloc(NULL, 10, NULL, plContext)); PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Free(array, plContext)); cleanup: PKIX_Shutdown(plContext); endTests("Memory Allocation"); return (0); }
int main(int argc, char **argv) { testApply(); testFree(); testNew(); testNewCopy(); testFill(); testGetSet(); testIncrementDecrement(); testPrint(); testPrintHeader(); testResize(); UnitTest_report(); }
void test_data_4( const char *zSystem, /* Database system name */ const char *zPattern, /* Run test cases that match this pattern */ int *pRc /* IN/OUT: Error code */ ){ Datatest4 aTest[] = { /* defn, nRec, nRepeat, bReopen */ { {DATA_RANDOM, 20,25, 500,600}, 10000, 10, 0 }, { {DATA_RANDOM, 20,25, 500,600}, 10000, 10, 1 }, }; int i; for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){ char *zName = getName4(zSystem, &aTest[i]); if( testCaseBegin(pRc, zPattern, "%s", zName) ){ doDataTest4(zSystem, &aTest[i], pRc); } testFree(zName); } }
extern "C" int main(int argc, char *argv[]) { SceUID fpl = sceKernelCreateFpl("fpl", PSP_MEMORY_PARTITION_USER, 0, 0x10, 8, NULL); void *temp; sceKernelAllocateFpl(fpl, &temp, NULL); checkpointNext("Objects:"); testFree(" Normal", fpl, &temp); testFree(" NULL", 0, &temp); testFree(" Invalid", 0xDEADBEEF, &temp); sceKernelDeleteFpl(fpl); testFree(" Deleted", fpl, &temp); fpl = sceKernelCreateFpl("fpl", PSP_MEMORY_PARTITION_USER, 0, 0x10, 8, NULL); sceKernelAllocateFpl(fpl, &temp, NULL); checkpointNext("Pointers:"); testFree(" Normal", fpl, temp); testFree(" NULL", fpl, NULL); testFree(" Invalid", fpl, (void *)0xDEADBEEF); testFree(" Already free", fpl, temp); sceKernelDeleteFpl(fpl); return 0; }