Example #1
0
int TestSetTransactionTimeout(CuTest *ct) {
	DB_ENV *dbenv;
	struct context *info;
	FILE *msgfile;
	char *path;
	db_timeout_t timeout;

	dbenv = NULL;
	if ((path = calloc(100, sizeof(char))) == NULL)
		return (ENOMEM);
	snprintf(path, 100, "%s%c%s", TEST_ENV, PATH_SEPARATOR[0], "msgfile");
	if ((msgfile = fopen(path, "w")) == NULL)
		return (EINVAL);
	info = ct->context;
	info->fp = msgfile;
	info->path = path;
	/* txn timeout: reset at run-time. */
	ENV
	CuAssertTrue(ct,
	    dbenv->set_timeout(dbenv, 37, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct, dbenv->open(dbenv,
	    TEST_ENV, DB_CREATE | DB_INIT_LOCK, 0666) == 0);
	CuAssertTrue(ct,
	    dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct, timeout == 37);
	ENV
	/* New transaction timeout is ignored when joining the environment. */
	CuAssertTrue(ct,
	    dbenv->set_timeout(dbenv, 63, DB_SET_TXN_TIMEOUT) == 0);
	/* Redirect the error message to suppress the warning. */
	dbenv->set_msgfile(dbenv, msgfile);
	CuAssertTrue(ct, dbenv->open(dbenv, TEST_ENV, DB_JOINENV, 0666) == 0);
	CuAssertTrue(ct,
	    dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct, timeout == 37);
	/* Direct the error message back to the standard output. */
	dbenv->set_msgfile(dbenv, NULL);
	/* Re-config the transaction timeout after opening the environment. */
	CuAssertTrue(ct,
	    dbenv->set_timeout(dbenv, 63, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct,
	    dbenv->get_timeout(dbenv, &timeout, DB_SET_TXN_TIMEOUT) == 0);
	CuAssertTrue(ct, timeout == 63);
	return (0);
}
Example #2
0
int TestSetLogMax(CuTest *ct) {
	DB_ENV *dbenv;
	struct context *info;
	FILE *msgfile;
	char *path;
	u_int32_t v;

	dbenv = NULL;
	if ((path = calloc(100, sizeof(char))) == NULL)
		return (ENOMEM);
	snprintf(path, 100, "%s%c%s", TEST_ENV, PATH_SEPARATOR[0], "msgfile");
	if ((msgfile = fopen(path, "w")) == NULL)
		return (EINVAL);
	info = ct->context;
	info->fp = msgfile;
	info->path = path;
	/* lg_max: reset at run-time. */
	ENV
	CuAssertTrue(ct, dbenv->set_lg_max(dbenv, 37 * 1024 * 1024) == 0);
	CuAssertTrue(ct, dbenv->open(dbenv,
	    TEST_ENV, DB_CREATE | DB_INIT_LOG, 0666) == 0);
	CuAssertTrue(ct, dbenv->get_lg_max(dbenv, &v) == 0);
	CuAssertTrue(ct, v == 37 * 1024 * 1024);
	ENV
	/* New log maximum size is ignored when joining the environment. */
	CuAssertTrue(ct, dbenv->set_lg_max(dbenv, 63 * 1024 * 1024) == 0);
	/* Redirect the error message to suppress the warning. */
	dbenv->set_msgfile(dbenv, msgfile);
	CuAssertTrue(ct, dbenv->open(dbenv, TEST_ENV, DB_JOINENV, 0666) == 0);
	CuAssertTrue(ct, dbenv->get_lg_max(dbenv, &v) == 0);
	CuAssertTrue(ct, v == 37 * 1024 * 1024);
	/* Direct the error message back to the standard output. */
	dbenv->set_msgfile(dbenv, NULL);
	/* Re-config the log maximum size after opening the environment. */
	CuAssertTrue(ct, dbenv->set_lg_max(dbenv, 63 * 1024 * 1024) == 0);
	CuAssertTrue(ct, dbenv->get_lg_max(dbenv, &v) == 0);
	CuAssertTrue(ct, v == 63 * 1024 * 1024);
	return (0);
}