#include <dpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#ifdef _MSC_VER
#if _MSC_VER < 1900
#define PRId64 "I64d"
#define PRIu64 "I64u"
#endif
#endif
#ifndef PRIu64
#include <inttypes.h>
#endif
#define DPI_TEST_POOL_MIN_SESSIONS 3
#define DPI_TEST_POOL_MAX_SESSIONS 9
#define DPI_TEST_POOL_SESSION_INCREMENT 2
typedef struct dpiTestCase dpiTestCase;
typedef struct dpiTestParams dpiTestParams;
typedef struct dpiTestSuite dpiTestSuite;
typedef int (*dpiTestCaseFunction)(dpiTestCase *testCase,
dpiTestParams *params);
struct dpiTestParams {
const char *mainUserName;
uint32_t mainUserNameLength;
const char *mainPassword;
uint32_t mainPasswordLength;
const char *proxyUserName;
uint32_t proxyUserNameLength;
const char *proxyPassword;
uint32_t proxyPasswordLength;
const char *editionUserName;
uint32_t editionUserNameLength;
const char *editionPassword;
uint32_t editionPasswordLength;
const char *editionName;
uint32_t editionNameLength;
const char *connectString;
uint32_t connectStringLength;
const char *dirName;
uint32_t dirNameLength;
const char *adminUserName;
uint32_t adminUserNameLength;
const char *adminPassword;
uint32_t adminPasswordLength;
};
struct dpiTestCase {
const char *description;
dpiTestCaseFunction func;
dpiConn *conn;
dpiConn *adminConn;
uint64_t sid;
uint64_t roundTrips;
int skipped;
};
struct dpiTestSuite {
uint32_t numTestCases;
uint32_t allocatedTestCases;
uint32_t minTestCaseId;
dpiTestCase *testCases;
dpiTestParams params;
FILE *logFile;
};
int dpiTestCase_cleanupSodaColl(dpiTestCase *testCase, dpiSodaColl *coll);
int dpiTestCase_dropAllSodaColls(dpiTestCase *testCase, dpiSodaDb *db);
int dpiTestCase_expectAnyError(dpiTestCase *testCase,
const char **expectedErrors);
int dpiTestCase_expectAnyErrorInfo(dpiTestCase *testCase,
const dpiErrorInfo *errorInfo, const char **expectedErrors);
int dpiTestCase_expectDoubleEqual(dpiTestCase *testCase, double actualValue,
double expectedValue);
int dpiTestCase_expectError(dpiTestCase *testCase, const char *expectedError);
int dpiTestCase_expectErrorInfo(dpiTestCase *testCase,
const dpiErrorInfo *erorInfo, const char *expectedError);
int dpiTestCase_expectIntEqual(dpiTestCase *testCase, int64_t actualValue,
int64_t expectedValue);
int dpiTestCase_expectRoundTripsEqual(dpiTestCase *testCase, uint64_t expected);
int dpiTestCase_expectStringEqual(dpiTestCase *testCase, const char *actual,
uint32_t actualLength, const char *expected, uint32_t expectedLength);
int dpiTestCase_expectTimestampEqual(dpiTestCase *testCase,
const dpiTimestamp *timestamp, const dpiTimestamp *expectedTimestamp);
int dpiTestCase_expectUintEqual(dpiTestCase *testCase, uint64_t actualValue,
uint64_t expectedValue);
int dpiTestCase_getConnection(dpiTestCase *testCase, dpiConn **conn);
int dpiTestCase_getDatabaseVersionInfo(dpiTestCase *testCase,
dpiVersionInfo **versionInfo);
int dpiTestCase_getPool(dpiTestCase *testCase, dpiPool **pool);
int dpiTestCase_getSodaDb(dpiTestCase *testCase, dpiSodaDb **db);
int dpiTestCase_setFailed(dpiTestCase *testCase, const char *message);
int dpiTestCase_setFailedFromError(dpiTestCase *testCase);
int dpiTestCase_setFailedFromErrorInfo(dpiTestCase *testCase,
dpiErrorInfo *info);
int dpiTestCase_setSkipped(dpiTestCase *testCase, const char *message);
int dpiTestCase_setSkippedIfVersionTooOld(dpiTestCase *testCase,
int clientOnly, unsigned minVersionNum, unsigned minReleaseNum);
int dpiTestCase_setupRoundTripChecker(dpiTestCase *testCase,
dpiTestParams *params);
int dpiTestCase_updateRoundTrips(dpiTestCase *testCase);
void dpiTestSuite_addCase(dpiTestCaseFunction func, const char *description);
void dpiTestSuite_getClientVersionInfo(dpiVersionInfo **versionInfo);
void dpiTestSuite_getContext(dpiContext **context);
void dpiTestSuite_getErrorInfo(dpiErrorInfo *errorInfo);
void dpiTestSuite_initialize(uint32_t minTestCaseId);
int dpiTestSuite_run();