Esempio n. 1
0
void
tsc_update (int ctype, int conc, char * text)
{
  printf ("Update Test\n");
  t1_window (&tw1, "CR1", hdbc1, text, ctype, 00, 5, conc, NULL);
  t1_window (&tw2, "CR2", hdbc2, text, ctype, 00, 5, conc, NULL);

  tw_fetch (&tw1, SQL_FETCH_NEXT, 0);
  tw_fetch (&tw2, SQL_FETCH_NEXT, 0);

  SQLTransact (SQL_NULL_HENV, hdbc1, SQL_COMMIT);

  /*  strcpy (tw2.tw_set[1].t1_fs1, "upd1");
   * *tw_set_pos (&tw2, 2, SQL_UPDATE);
   */
  t1_update (&tw2, tw1.tw_set[1].t1_row_no, "upd1");
  t1_delete (&tw2, tw1.tw_set[2].t1_row_no);
  tw_fetch (&tw1, SQL_FETCH_RELATIVE, 0);
  T_CCOL (&tw1, 1, t1_fs1, "upd1");
  SQLTransact (SQL_NULL_HENV, hdbc1, SQL_COMMIT);
  tw_fetch (&tw1, SQL_FETCH_RELATIVE, 0);
  SQLTransact (SQL_NULL_HENV, hdbc1, SQL_COMMIT);

  tw_set_pos (&tw2, 2, SQL_ADD);
  t1_delete (&tw2, tw2.tw_set[0].t1_row_no);

  tw_fetch (&tw1, SQL_FETCH_RELATIVE, 0);
  SQLTransact (SQL_NULL_HENV, hdbc1, SQL_COMMIT);

  tw_fetch (&tw1, SQL_FETCH_NEXT, 0);
  tw_fetch (&tw1, SQL_FETCH_NEXT, 0);
  tw_fetch (&tw1, SQL_FETCH_NEXT, 0);
  tw_fetch (&tw1, SQL_FETCH_PRIOR, 0);
  tw_fetch (&tw1, SQL_FETCH_PRIOR, 0);
  tw_fetch (&tw1, SQL_FETCH_PRIOR, 0);
}
Esempio n. 2
0
static int
test_rbt_gen(char *filename, char *command, char *testname,
	     isc_result_t exp_result)
{
	int		rval;
	int		result;
	dns_rbt_t	*rbt;
	isc_result_t	isc_result;
	isc_result_t	dns_result;
	isc_mem_t	*mctx;
	isc_entropy_t	*ectx;
	dns_name_t	*dns_name;

	result = T_UNRESOLVED;

	if (strcmp(command, "create") != 0)
		t_info("testing using name %s\n", testname);

	mctx = NULL;
	ectx = NULL;

	isc_result = isc_mem_create(0, 0, &mctx);
	if (isc_result != ISC_R_SUCCESS) {
		t_info("isc_mem_create: %s: exiting\n",
		       dns_result_totext(isc_result));
		return(T_UNRESOLVED);
	}

	isc_result = isc_entropy_create(mctx, &ectx);
	if (isc_result != ISC_R_SUCCESS) {
		t_info("isc_entropy_create: %s: exiting\n",
		       dns_result_totext(isc_result));
		isc_mem_destroy(&mctx);
		return(T_UNRESOLVED);
	}

	isc_result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
	if (isc_result != ISC_R_SUCCESS) {
		t_info("isc_hash_create: %s: exiting\n",
		       dns_result_totext(isc_result));
		isc_entropy_detach(&ectx);
		isc_mem_destroy(&mctx);
		return(T_UNRESOLVED);
	}

	rbt = NULL;
	if (rbt_init(filename, &rbt, mctx) != 0) {
		if (strcmp(command, "create") == 0)
			result = T_FAIL;
		isc_hash_destroy();
		isc_entropy_detach(&ectx);
		isc_mem_destroy(&mctx);
		return(result);
	}

	/*
	 * Now try the database command.
	 */
	if (strcmp(command, "create") == 0) {
		result = T_PASS;
	} else if (strcmp(command, "add") == 0) {
		if (create_name(testname, mctx, &dns_name) == 0) {
			dns_result = dns_rbt_addname(rbt, dns_name, dns_name);

			if (dns_result != ISC_R_SUCCESS)
				delete_name(dns_name, mctx);

			if (dns_result == exp_result) {
				if (dns_result == ISC_R_SUCCESS) {
					rval = t1_search(testname, rbt, mctx,
							 &dns_result);
					if (rval == 0) {
					     if (dns_result == ISC_R_SUCCESS) {
						     result = T_PASS;
					     } else {
						     result = T_FAIL;
					     }
					} else {
						t_info("t1_search failed\n");
						result = T_UNRESOLVED;
					}
				} else {
					result = T_PASS;
				}
			} else {
				t_info("dns_rbt_addname returned %s, "
				       "expected %s\n",
				       dns_result_totext(dns_result),
				       dns_result_totext(exp_result));
				result = T_FAIL;
			}
		} else {
			t_info("create_name failed\n");
			result = T_UNRESOLVED;
		}
	} else if ((strcmp(command, "delete") == 0) ||
		   (strcmp(command, "nuke") == 0)) {
		rval = t1_delete(testname, rbt, mctx, &dns_result);
		if (rval == 0) {
			if (dns_result == exp_result) {
				rval = t1_search(testname, rbt, mctx,
						 &dns_result);
				if (rval == 0) {
					if (dns_result == ISC_R_SUCCESS) {
						t_info("dns_rbt_deletename "
						       "didn't delete "
						       "the name");
						result = T_FAIL;
					} else {
						result = T_PASS;
					}
				}
			} else {
				t_info("delete returned %s, expected %s\n",
					dns_result_totext(dns_result),
					dns_result_totext(exp_result));
				result = T_FAIL;
			}
		}
	} else if (strcmp(command, "search") == 0) {
		rval = t1_search(testname, rbt, mctx, &dns_result);
		if (rval == 0) {
			if (dns_result == exp_result) {
				result = T_PASS;
			} else {
				t_info("find returned %s, expected %s\n",
					dns_result_totext(dns_result),
					dns_result_totext(exp_result));
				result = T_FAIL;
			}
		}
	}

	dns_rbt_destroy(&rbt);
	isc_hash_destroy();
	isc_entropy_detach(&ectx);
	isc_mem_destroy(&mctx);
	return(result);
}