Ejemplo n.º 1
0
END_TEST

START_TEST(test_delete)
{
	bool s;
	struct hdfs_object *e = NULL;
	const char *tf = "/HADOOFUS_TEST_DELETE",
	      *client = "HADOOFUS_CLIENT";

	hdfs_create(h, tf, 0644, client, true/*overwrite*/,
	    false/*createparent*/, 1/*replication*/, 64*1024*1024, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	s = hdfs_delete(h, tf, false/*recurse*/, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert_msg(s, "delete returned false");
}
Ejemplo n.º 2
0
END_TEST

START_TEST (test_read_string)
{
    FILE *f = fopen ("test_files/test_string_read.scm", "r");
    if (f == NULL)
        ck_abort_msg ("file reading didn't work\n");
    object *o = read (f);
    ck_assert_str_eq (o->data.string.value, "abc");
}
Ejemplo n.º 3
0
END_TEST

START_TEST(test_abandonBlock)
{
	bool s;
	struct hdfs_object *e = NULL, *lb, *bl;
	const char *tf = "/HADOOFUS_TEST_ABANDONBLOCK",
	      *client = "HADOOFUS_CLIENT";

	// Create the file first
	hdfs_create(h, tf, 0644, client, true/*overwrite*/,
	    false/*createparent*/, 1/*replication*/, 64*1024*1024, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	mark_point();

	// XXX this must be updated to cover v2.0+ (last_block/fileid)
	lb = hdfs_addBlock(h, tf, client, NULL, NULL, 0, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert(!hdfs_object_is_null(lb));

	mark_point();

	bl = hdfs_block_from_located_block(lb);
	hdfs_object_free(lb);

	mark_point();

	hdfs_abandonBlock(h, bl, tf, client, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	hdfs_object_free(bl);
	mark_point();

	// Cleanup
	s = hdfs_delete(h, tf, false/*recurse*/, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert_msg(s, "delete returned false");
}
Ejemplo n.º 4
0
END_TEST
  
START_TEST(test_check_failure_lnos)
{
  int i;
  int line_no;
  int passed = 0;
  int failed;
  TestResult *tr;
  
  /* Create list of line numbers where failures occurred */
  rewind(line_num_failures);

  for (i = 0; i < sub_ntests; i++) {
    if (master_tests[i].failure_type == CK_PASS) {
      passed++;
      continue;
    }

    failed = i - passed;

    ck_assert_msg(i - passed <= sub_nfailed, NULL);
    tr = tr_fail_array[failed];
    ck_assert_msg(tr != NULL, NULL);
    line_no = get_next_failure_line_num(line_num_failures);

    if(line_no == -1)
    {
      ck_abort_msg("Did not find the %dth failure line number for suite %s, msg %s",
        (failed+1), tr_tcname(tr), tr_msg(tr));
    }

    if (line_no > 0 && tr_lno(tr) != line_no) {
      ck_abort_msg("For test %d (failure %d): Expected lno %d, got %d for suite %s, msg %s",
               i, failed, line_no, tr_lno(tr), tr_tcname(tr), tr_msg(tr));
    }    
  }

  /* At this point, there should be no remaining failures */
  line_no = get_next_failure_line_num(line_num_failures);
  ck_assert_msg(line_no == -1,
    "No more failure line numbers expected, but found %d", line_no);
}
Ejemplo n.º 5
0
END_TEST

START_TEST (test_nested_lambda)
{
    FILE *f = fopen ("test_files/test_nested_lambda.scm", "r");
    if (f == NULL)
        ck_abort_msg ("file reading didn't work\n");
    interpret (f, true);

}
Ejemplo n.º 6
0
END_TEST

START_TEST(test_renewLease)
{
	struct hdfs_object *e = NULL;

	hdfs_renewLease(h, "HADOOFUS_CLIENT", &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
}
Ejemplo n.º 7
0
END_TEST

START_TEST(test_path_append_zero)
{
    Node *path = path_append (0.0, 0.0);
    if (path_current_node(path)->x != 0.0 ||
            path_current_node(path)->y != 0.0)
    {
        ck_abort_msg("Zero is a valid value");
    }
}
Ejemplo n.º 8
0
END_TEST

START_TEST(test_money_create_zero)
{
    Money *m = money_create(0, "USD");

    if (money_amount(m) != 0)
    {
        ck_abort_msg("Zero is a valid amount of money");
    }
}
Ejemplo n.º 9
0
END_TEST

START_TEST(test_fork2_pass)
{
  pid_t pid;
  pid_t pid2;
  
  if((pid = check_fork()) < 0) {
    ck_abort_msg("Failed to fork new process");
  } else if (pid > 0) {
    if((pid2 = check_fork()) < 0) {
      ck_abort_msg("Failed to fork new process");
    } else if (pid2 == 0) {
      ck_assert_msg(1, NULL);
      check_waitpid_and_exit(0);
    }
    check_waitpid_and_exit(pid2);
  }
  check_waitpid_and_exit(pid);
}
Ejemplo n.º 10
0
END_TEST

START_TEST (words_with_unknown_letters_should_be_rejected)
{
    int rc = varnam_learn (varnam_instance, "test");
    if (rc != VARNAM_ERROR) {
        ck_abort_msg ("Expected return code to be VARNAM_ERROR");
    }
    ck_assert_str_eq (varnam_get_last_error (varnam_instance),
            "Can't process 't'. One or more characters in 'test' are not known");
}
Ejemplo n.º 11
0
END_TEST

START_TEST(test_getBlockLocations)
{
	struct hdfs_object *e = NULL, *bls;
	bls = hdfs_getBlockLocations(h, "/", 0L, 1000L, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert_msg(hdfs_object_is_null(bls));
	ck_assert_msg(hdfs_null_type(bls) == H_LOCATED_BLOCKS);
}
Ejemplo n.º 12
0
void 
assert_error (int value)
{
    strbuf *string = NULL;
    if (value != VARNAM_ERROR) {
        string = strbuf_init (50);
        strbuf_addf (string, "Expected VARNAM_ERROR, but got %d. %s", value, 
                varnam_get_last_error (varnam_instance));
        ck_abort_msg (strbuf_to_s (string));
    }
}
Ejemplo n.º 13
0
void
setup(void)
{
    ulcd = ulcd_new();
    ulcd_set_baud_rate(ulcd, 115200);
    strcpy(ulcd->device, "/dev/ttyAMA0");

    if (ulcd_open_serial_device(ulcd)) {
        ck_abort_msg("Could not open serial port.");
    }
    ulcd_set_serial_parameters(ulcd);
}
Ejemplo n.º 14
0
END_TEST

START_TEST(test_getStats)
{
	struct hdfs_object *e = NULL, *stats;

	stats = hdfs_getStats(h, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	hdfs_object_free(stats);
}
Ejemplo n.º 15
0
END_TEST

START_TEST(test_getServerDefaults)
{
	struct hdfs_object *object, *e = NULL;

	object = hdfs2_getServerDefaults(h, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	hdfs_object_free(object);
}
Ejemplo n.º 16
0
END_TEST

START_TEST(test_fork2_fail)
{
  pid_t pid;
  pid_t pid2;
  
  if((pid = check_fork()) < 0) {
    ck_abort_msg("Failed to fork new process");
  } else if (pid > 0) {
    if((pid2 = check_fork()) < 0) {
      ck_abort_msg("Failed to fork new process");
    } else if (pid2 == 0) {
      ck_abort_msg("Expected fail");
      check_waitpid_and_exit(0);
    }
    check_waitpid_and_exit(pid2);
    ck_abort_msg("Expected fail");
  }
  check_waitpid_and_exit(pid);
}
Ejemplo n.º 17
0
END_TEST

START_TEST(test_atree_random_value)
{
    ATree *at;
    gint  result;
    gint  key;
    gint  data;
    gint  *random;
    
    at = a_tree_new();
    
    if (at == NULL)
    {
        ck_abort_msg ("Failed to create ATree\n");
    }
    else
    {
        key  = 1;
        data = 1;
        
        g_rand_set_seed( at->random, 0 );
        
        result = atree_insert( at, GINT_TO_POINTER(&key), GINT_TO_POINTER(&data) );
        ck_assert_int_eq( result, 0 );
		
		random = atree_random_value( at );
        
        if (random == NULL)
        {
            ck_abort_msg ("random values is NULL\n");
        }
        else
        {
            ck_assert_int_eq( *random, data );
        }
        
        a_tree_destroy( at );
    }
}
Ejemplo n.º 18
0
END_TEST
START_TEST (test_enq_add_ring)
{
  int err;
  if ((err =
       memif_init (control_fd_update, TEST_APP_NAME, NULL,
		   NULL, NULL)) != MEMIF_ERR_SUCCESS)
    ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));

  memif_connection_t conn;
  conn.msg_queue = NULL;
  conn.rx_queues = (memif_queue_t *) malloc (sizeof (memif_queue_t));
  conn.tx_queues = (memif_queue_t *) malloc (sizeof (memif_queue_t));

  memif_queue_t *mq = conn.tx_queues;
  uint8_t dir = MEMIF_RING_S2M;
  mq->int_fd = 5;
  mq->offset = 0;
  mq->log2_ring_size = 10;

  if ((err = memif_msg_enq_add_ring (&conn, 0, dir)) != MEMIF_ERR_SUCCESS)
    ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));

  memif_msg_queue_elt_t *e = conn.msg_queue;

  ck_assert_uint_eq (e->msg.type, MEMIF_MSG_TYPE_ADD_RING);
  ck_assert_int_eq (e->fd, mq->int_fd);

  memif_msg_add_ring_t *ar = &e->msg.add_ring;

  ck_assert_uint_eq (ar->index, 0);
  ck_assert_uint_eq (ar->offset, mq->offset);
  ck_assert_uint_eq (ar->log2_ring_size, mq->log2_ring_size);
  ck_assert (ar->flags & MEMIF_MSG_ADD_RING_FLAG_S2M);

  dir = MEMIF_RING_M2S;
  if ((err = memif_msg_enq_add_ring (&conn, 0, dir)) != MEMIF_ERR_SUCCESS)
    ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
  queue_free (&conn.msg_queue);
}
Ejemplo n.º 19
0
END_TEST

START_TEST(test_getBlockLocations2)
{
	struct hdfs_object *e = NULL, *e2 = NULL, *bls;
	const char *tf = "/HADOOFUS_TEST_GET_BLOCK_LOCATIONS2",
	      *client = "HADOOFUS_CLIENT";

	hdfs_create(h, tf, 0644, client, true/*overwrite*/,
	    false/*createparent*/, 1/*replication*/, 64*1024*1024, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	bls = hdfs_getBlockLocations(h, tf, 0L, 1000L, &e);
	hdfs_delete(h, tf, false/*recurse*/, &e2);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	if (e2)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e2));

	ck_assert_msg(bls->ob_type == H_LOCATED_BLOCKS);
}
Ejemplo n.º 20
0
END_TEST

START_TEST(test_setQuota)
{
	bool s;
	struct hdfs_object *e = NULL;
	const char *tf = "/HADOOFUS_TEST_SETQUOTA";

	s = hdfs_mkdirs(h, tf, 0755, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert_msg(s, "mkdirs returned false");

	hdfs_setQuota(h, tf, -1, -1, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	s = hdfs_delete(h, tf, false/*recurse*/, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert_msg(s, "delete returned false");
}
Ejemplo n.º 21
0
END_TEST

START_TEST(test_getFileInfo)
{
	struct hdfs_object *e = NULL, *fs;

	fs = hdfs_getFileInfo(h, "/", &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert(!hdfs_object_is_null(fs));

	hdfs_object_free(fs);
}
Ejemplo n.º 22
0
END_TEST

START_TEST (varnam_export_full)
{
    int rc, pcnt, wcnt, i;
    float filecnt;
    strbuf* f; strbuf* error;

    f = strbuf_init (20);
    pcnt = execute_query_int (varnam_instance->internal->known_words, "select count(*) from patterns_content;");
    wcnt = execute_query_int (varnam_instance->internal->known_words, "select count(*) from words;");

    rc = varnam_export_words (varnam_instance, 2, "output/", VARNAM_EXPORT_FULL, NULL);
    assert_success (rc);

    filecnt = pcnt / 2;
    for (i = 0; i < (int) ceil (filecnt); i++) {
        strbuf_clear (f);
        strbuf_addf (f, "output/%d.patterns.txt", i);
        if (!file_exist (strbuf_to_s (f))) {
            error = strbuf_init (10);
            strbuf_addf (error, "Failed to find file: %s\n", strbuf_to_s (f));
            ck_abort_msg (strbuf_to_s (error));
        }
    }

    filecnt = wcnt / 2;
    for (i = 0; i < (int) ceil (filecnt); i++) {
        strbuf_clear (f);
        strbuf_addf (f, "output/%d.words.txt", i);
        if (!file_exist (strbuf_to_s (f))) {
            error = strbuf_init (10);
            strbuf_addf (error, "Failed to find file: %s\n", strbuf_to_s (f));
            ck_abort_msg (strbuf_to_s (error));
        }
    }

    strbuf_destroy (f);
}
Ejemplo n.º 23
0
END_TEST

START_TEST(test_getListing)
{
	struct hdfs_object *e = NULL, *listing;

	listing = hdfs_getListing(h, "/", NULL, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	ck_assert(!hdfs_object_is_null(listing));

	hdfs_object_free(listing);
}
Ejemplo n.º 24
0
static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
                       size_t length, void *user_data)
{
    if (size_recv != position) {
        ck_abort_msg("Bad position");
    }

    if (length == 0) {
        file_recv = 1;
        return;
    }

    VLA(uint8_t, f_data, length);
    memset(f_data, num, length);
    ++num;

    if (memcmp(f_data, data, length) == 0) {
        size_recv += length;
    } else {
        ck_abort_msg("FILE_CORRUPTED");
    }
}
Ejemplo n.º 25
0
END_TEST

START_TEST(test_distributedUpgradeProgress)
{
	struct hdfs_object *e, *us;

	e = NULL;

	us = hdfs_distributedUpgradeProgress(h, HDFS_UPGRADEACTION_STATUS, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	hdfs_object_free(us);

	us = hdfs_distributedUpgradeProgress(h, HDFS_UPGRADEACTION_DETAILED, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));
	hdfs_object_free(us);

#if 0
	us = hdfs_distributedUpgradeProgress(HDFS_UPGRADEACTION_FORCE_PROCEED);
#endif
}
Ejemplo n.º 26
0
END_TEST

START_TEST(test_setSafeMode)
{
	struct hdfs_object *e;
	bool b;

	e = NULL;
	b = hdfs_setSafeMode(h, HDFS_SAFEMODE_GET, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	b = hdfs_setSafeMode(h, HDFS_SAFEMODE_ENTER, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	b = hdfs_setSafeMode(h, HDFS_SAFEMODE_LEAVE, &e);
	if (e)
		ck_abort_msg("exception: %s", hdfs_exception_get_message(e));

	(void)b;
}
Ejemplo n.º 27
0
static void remove_library_from_list(const char *library, char **list,
                                     size_t list_size)
{
    for (size_t i = 0; i < list_size; ++i) {
        if (list[i] != NULL && strcmp(library, list[i]) == 0) {
            /* found library need to be removed from list */
            free(list[i]);
            list[i] = NULL;
            return;
        }
    }

    ck_abort_msg("Cannot find expected library: %s", library);
}
Ejemplo n.º 28
0
END_TEST

START_TEST(test_check_tcnames)
{
  const char *tcname;   
  tcname = tr_tcname(tr_all_array[_i]);
  if (strcmp(tcname, master_tests[_i].tcname) != 0) {
    char *emsg = (char *)malloc (MAXSTR);
    snprintf(emsg, MAXSTR,"Expected %s, got %s",
             master_tests[_i].tcname, tcname);
    ck_abort_msg(emsg);
    free(emsg);
  } 
}
Ejemplo n.º 29
0
static void tox_connection_status(Tox *tox, TOX_CONNECTION connection_status, void *user_data)
{
    if (*((uint32_t *)user_data) != 974536) {
        return;
    }

    if (connected_t1 && !connection_status) {
        ck_abort_msg("Tox went offline");
    }

    ck_assert_msg(connection_status == TOX_CONNECTION_UDP, "wrong status %u", connection_status);

    connected_t1 = connection_status;
}
Ejemplo n.º 30
0
void
execute_query (sqlite3* db, const char* sql)
{
    int rc;
    sqlite3_stmt* stmt;
    strbuf* error;

    rc = sqlite3_prepare_v2 (db, sql, -1, &stmt, NULL);
    if (rc != SQLITE_OK) {
        error = strbuf_init (50);
        strbuf_addf (error, "Failed to prepare query: %s. Return code was: %d\n", sql, rc);
        ck_abort_msg (strbuf_to_s (error));
    }

    rc = sqlite3_step (stmt);
    if (rc != SQLITE_DONE) {
        error = strbuf_init (50);
        strbuf_addf (error, "Failed to execute query: %s. Return code was: %d\n", sql, rc);
        ck_abort_msg (strbuf_to_s (error));
    }

    sqlite3_finalize (stmt);
}