コード例 #1
0
ファイル: multrpc.c プロジェクト: surajpkn/flux-core
int main (int argc, char *argv[])
{
    flux_msg_t *msg;
    flux_t h;
    flux_reactor_t *reactor;

    plan (35);

    (void)setenv ("FLUX_CONNECTOR_PATH", CONNECTOR_PATH, 0);
    ok ((h = flux_open ("loop://", FLUX_O_COPROC)) != NULL,
        "opened loop connector");
    if (!h)
        BAIL_OUT ("can't continue without loop handle");
    ok ((reactor = flux_get_reactor (h)) != NULL,
        "obtained reactor");
    if (!reactor)
        BAIL_OUT ("can't continue without reactor");

    flux_fatal_set (h, fatal_err, NULL);
    flux_fatal_error (h, __FUNCTION__, "Foo");
    ok (fatal_tested == true,
        "flux_fatal function is called on fatal error");

    /* create nodeset for last _then test */
    ok ((then_ns = nodeset_create ()) != NULL,
        "nodeset created ok");

    ok (flux_msghandler_addvec (h, htab, htablen, NULL) == 0,
        "registered message handlers");
    /* test continues in rpctest_begin_cb() so that rpc calls
     * can sleep while we answer them
     */
    ok ((msg = flux_request_encode ("rpctest.begin", NULL)) != NULL
        && flux_send (h, msg, 0) == 0,
        "sent message to initiate test");
    ok (flux_reactor_run (reactor, 0) == 0,
        "reactor completed normally");
    flux_msg_destroy (msg);

    /* Check result of last _then test */
    ok (nodeset_count (then_ns) == 128,
        "then callback worked with correct nodemap");
    nodeset_destroy (then_ns);
    flux_rpc_destroy (then_r);

    flux_close (h);

    done_testing();
    return (0);
}
コード例 #2
0
ファイル: test.cpp プロジェクト: svn2github/ACE-Middleware
int ACE_TMAIN (int argc, ACE_TCHAR * argv[])
{
    try
    {
        if (argc < 1)
        {
            ACE_ERROR ((LM_ERROR, ACE_TEXT ("Incorrect count of arguments. Path to deployment plan has not been specified.\n")));
            return 1;
        }
        //parsing plan
        DAnCE::Config_Handlers::XML_File_Intf file (argv[1]);
        file.add_search_path (ACE_TEXT ("DANCE_ROOT"), ACE_TEXT ("/docs/schema/"));
        file.add_search_path (ACE_TEXT ("CIAO_ROOT"), ACE_TEXT ("/docs/schema/"));
        file.add_search_path (ACE_TEXT ("TAO_ROOT"), ACE_TEXT ("/docs/schema/"));
        auto_ptr<Deployment::DeploymentPlan>  plan (file.release_plan());

        //check instance references to corresponding implementations
        for ( ::CORBA::ULong i = 0; i < plan->instance.length(); i++)
        {
            if (plan->instance[i].implementationRef > plan->implementation.length() - 1)
            {
                ACE_ERROR ((LM_ERROR,
                            ACE_TEXT ("incorrect implementationRef in instance %C.\n"), plan->instance[i].name.in()));
                return 1;
            }
        }

        //check artifact reference for implementations of Home objects
        for ( ::CORBA::ULong i = 0; i < plan->implementation.length(); i++)
        {
            if (plan->implementation[i].artifactRef.length() > 0)
            {
                if (plan->implementation[i].artifactRef[0] > plan->artifact.length() - 1)
                {
                    ACE_ERROR ((LM_ERROR,
                                ACE_TEXT ("incorrect artifactRef in the implementation %C.\n"), plan->implementation[i].name.in()));
                    return 1;
                }
            }
        }
    }
    catch (...)
    {
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unexpected exception")));
        return 1;
    }

    return 0;
}
コード例 #3
0
ファイル: realms-t.c プロジェクト: bagdxk/openafs
int
main(int argc, char **argv)
{
    afstest_SkipTestsIfBadHostname();

    plan(113);

    test_edges();
    test_no_config_files();
    test_with_config_files();
    test_update_config_files();
    test_set_local_realms(); /* must be the last test */

    return 0;
}
コード例 #4
0
ファイル: rbtree-t.c プロジェクト: bagdxk/openafs
int
main(void)
{
    struct opr_rbtree head;

    plan(3);

    opr_rbtree_init(&head);
    ok(1, "Initialising the tree works");

    ok(createTree(&head), "Creating tree with 1000 nodes works");
    ok(destroyTree(&head), "Tree retains consistency as nodes deleted");

    return 0;
}
コード例 #5
0
ファイル: todo.c プロジェクト: ImmobilienScout24/icinga-core
int main () {
    setvbuf(stdout, NULL, _IONBF, 0);
    plan(6);
    todo();
    ok(0, "foo");
    ok(1, "bar");
    ok(1, "baz");
    endtodo;
    todo("im not ready");
    ok(0, "quux");
    ok(1, "thud");
    ok(1, "wombat");
    endtodo;
    done_testing();
}
コード例 #6
0
ファイル: submit.c プロジェクト: flux-framework/flux-core
int main (int argc, char *argv[])
{
    struct queue *queue;

    plan (NO_PLAN);

    if (!(queue = queue_create (true)))
        BAIL_OUT ("queue_create() failed");

    single_job_check (queue);
    multi_job_check (queue);

    queue_destroy (queue);
    done_testing ();
}
コード例 #7
0
ファイル: todo.c プロジェクト: e-user/libtap
int main () {
    setvbuf(stdout, NULL, _IONBF, 0);
    plan(6);
    todo();
    ok(0, "foo");
    ok(1, "bar");
    ok(1, "baz");
    endtodo;
    todo("im not ready");
    ok(0, "quux");
    ok(1, "thud");
    ok(1, "wombat");
    endtodo;
    return exit_status();
}
コード例 #8
0
ファイル: todo-t.c プロジェクト: 0x-ff/libmysql-android
int main()
{
  plan(4);
  ok(1, NULL);
  ok(1, NULL);
  /*
    Tests in the todo region is expected to fail. If they don't,
    something is strange.
  */
  todo_start("Need to fix these");
  ok(0, NULL);
  ok(0, NULL);
  todo_end();
  return exit_status();
}
コード例 #9
0
ファイル: error.c プロジェクト: abw/hemp
int main(
    int argc, char **argv, char **env
) {
    plan(13);

    test_error_jump();
    /* test_error2() has been deprecated */
    test_error_macros();
    test_error_object();
    test_hemp_throw();

    test_error_finally();

    return done();
}
コード例 #10
0
ファイル: compute.c プロジェクト: mathieu74/Source
double			compute_object(t_ray ray, t_object object)
{
	double		len;

	len = 0;
	if (object.type == SPHERE)
		len = sphere(ray, object);
	else if (object.type == PLAN)
		len = plan(ray, object);
	else if (object.type == CYLINDER)
		len = cylinder(ray, object);
	else if (object.type == CONE)
		len = cone(ray, object);
	return (len);
}
コード例 #11
0
void DivePlannerPointsModel::createTemporaryPlan()
{
	// Get the user-input and calculate the dive info
	free_dps(&diveplan);
	int lastIndex = -1;
	for (int i = 0; i < rowCount(); i++) {
		divedatapoint p = at(i);
		int deltaT = lastIndex != -1 ? p.time - at(lastIndex).time : p.time;
		lastIndex = i;
		if (i == 0 && prefs.drop_stone_mode) {
			/* Okay, we add a first segment where we go down to depth */
			plan_add_segment(&diveplan, p.depth / prefs.descrate, p.depth, p.cylinderid, p.setpoint, true);
			deltaT -= p.depth / prefs.descrate;
		}
		if (p.entered)
			plan_add_segment(&diveplan, deltaT, p.depth, p.cylinderid, p.setpoint, true);
	}

	// what does the cache do???
	char *cache = NULL;
	struct divedatapoint *dp = NULL;
	for (int i = 0; i < MAX_CYLINDERS; i++) {
		cylinder_t *cyl = &displayed_dive.cylinder[i];
		if (cyl->depth.mm) {
			dp = create_dp(0, cyl->depth.mm, i, 0);
			if (diveplan.dp) {
				dp->next = diveplan.dp;
				diveplan.dp = dp;
			} else {
				dp->next = NULL;
				diveplan.dp = dp;
			}
		}
	}
#if DEBUG_PLAN
	dump_plan(&diveplan);
#endif
	if (recalcQ() && !diveplan_empty(&diveplan)) {
		plan(&diveplan, &cache, isPlanner(), false);
		emit calculatedPlanNotes();
	}
	// throw away the cache
	free(cache);
#if DEBUG_PLAN
	save_dive(stderr, &displayed_dive);
	dump_plan(&diveplan);
#endif
}
コード例 #12
0
ファイル: msgpuck.c プロジェクト: rtsisyk/msgpuck
static int
test_numbers()
{
	plan(96);
	header();

	test_read_int32(uint, 123, true);
	test_read_int32(uint, 12345, true);
	test_read_int32(uint, 2147483647, true);
	test_read_int32(uint, 2147483648, false);
	test_read_int32(int, -123, true);
	test_read_int32(int, -12345, true);
	test_read_int32(int, -2147483648, true);
	test_read_int32(int, -2147483649LL, false);
	test_read_int32(float, -1e2, false);
	test_read_int32(double, 1.2345, false);
	test_read_int32(map, 5, false);

	test_read_int64(uint, 123, true);
	test_read_int64(uint, 12345, true);
	test_read_int64(uint, 123456789, true);
	test_read_int64(uint, 9223372036854775807ULL, true);
	test_read_int64(uint, 9223372036854775808ULL, false);
	test_read_int64(int, -123, true);
	test_read_int64(int, -12345, true);
	test_read_int64(int, -123456789, true);
	test_read_int64(int, -9223372036854775807LL, true);
	test_read_int64(float, 100, false);
	test_read_int64(double, -5.4321, false);
	test_read_int64(array, 10, false);

	test_read_double(uint, 123, true);
	test_read_double(uint, 12345, true);
	test_read_double(uint, 123456789, true);
	test_read_double(uint, 1234567890000ULL, true);
	test_read_double(uint, 123456789123456789ULL, false);
	test_read_double(int, -123, true);
	test_read_double(int, -12345, true);
	test_read_double(int, -123456789, true);
	test_read_double(int, -1234567890000LL, true);
	test_read_double(int, -123456789123456789LL, false);
	test_read_double(float, 6.565e6, true);
	test_read_double(double, -5.555, true);
	test_read_double(strl, 100, false);

	footer();
	return check_plan();
}
コード例 #13
0
void goalCallback(const geometry_msgs::PointStamped::ConstPtr& msg){
	ROS_INFO_STREAM("goal update: "<< msg->point.x << "," << msg->point.y);
	if(planning)
		return;
	//update local goal
	goal.header.frame_id=msg->header.frame_id;
	goal.header.stamp=ros::Time(0);
	goal.point.x=msg->point.x;
	goal.point.y=msg->point.y;

	goalState[0]=goal.point.x;
	goalState[1]=goal.point.y;
	
	plan();
	sendWaypoint();
}
コード例 #14
0
ファイル: proto.c プロジェクト: surajpkn/flux-core
int main (int argc, char *argv[])
{

    plan (31);

    test_put (); // 3
    test_get (); // 8
    test_watch (); // 7
    test_unwatch (); // 2
    test_commit (); // 7
    test_getroot (); // 2
    test_setroot (); // 2

    done_testing();
    return (0);
}
コード例 #15
0
ファイル: MOpt.c プロジェクト: quietfanatic/ltm
int main () {
    plan(9);

    MSpec opt1 = { .Opt = {
            .type = MOPT,
            .flags = 0,
            .possible = (MSpec[]) {
                {   .Char = {
                        .type = MCHAR,
                        .flags = 0,
                        .c = 'a'
                    }
                }
            }
        }
    };
コード例 #16
0
ファイル: hkl-quaternion-t.c プロジェクト: picca/hkl
int main(void)
{
	plan(375);

	assignment();
	cmp();
	init_from_vector();
	init_from_angle_and_axe();
	times_quaternion();
	norm2();
	conjugate();
	to_matrix();
	to_angle_and_axe();

	return 0;
}
コード例 #17
0
ファイル: my_timer-t.c プロジェクト: 0x00xw/mysql-2
void do_tests()
{
  plan(49);

  ok(my_timer_init_ext() == 0, "my_timer_init_ext");

  test_create_and_delete();
  test_reset();
  test_timer();
  test_timer_reuse();
  test_independent_timers();
  test_concurrently("per-thread", test_timer_per_thread, THREADS, 5);
  test_reinitialization();

  my_timer_deinit();
}
コード例 #18
0
ファイル: msgpuck.c プロジェクト: rtsisyk/msgpuck
static int
test_doubles(void)
{
	plan(27);
	header();

	test_double((double) 1.0,
		    "\xcb\x3f\xf0\x00\x00\x00\x00\x00\x00", 9);
	test_double((double) 3.141592653589793,
		    "\xcb\x40\x09\x21\xfb\x54\x44\x2d\x18", 9);
	test_double((double) -1e99,
		    "\xcb\xd4\x7d\x42\xae\xa2\x87\x9f\x2e", 9);

	footer();
	return check_plan();
}
コード例 #19
0
/**
 * Function called to get a message for transmission.
 *
 * @param cls closure
 * @param buf_size number of bytes available in buf
 * @param buf where to copy the message, NULL on error (peer disconnect)
 * @return number of bytes copied to 'buf', can be 0 (without indicating an error)
 */
static size_t
transmit_message_callback (void *cls, size_t buf_size, void *buf)
{
  struct PeerPlan *pp = cls;
  struct GSF_RequestPlan *rp;
  size_t msize;

  pp->pth = NULL;
  if (NULL == buf)
  {
    /* failed, try again... */
    pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp);
    GNUNET_STATISTICS_update (GSF_stats,
                              gettext_noop
                              ("# transmission failed (core has no bandwidth)"),
                              1, GNUNET_NO);
    return 0;
  }
  rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap);
  if (NULL == rp)
  {
    pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp);
    return 0;
  }
  msize = GSF_pending_request_get_message_ (get_latest (rp), buf_size, buf);
  if (msize > buf_size)
  {
    /* buffer to small (message changed), try again */
    pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp);
    return 0;
  }
  /* remove from root, add again elsewhere... */
  GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->priority_heap));
  rp->hn = NULL;
  rp->last_transmission = GNUNET_TIME_absolute_get ();
  rp->transmission_counter++;
  total_delay++;
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Executing plan %p executed %u times, planning retransmission\n",
              rp, rp->transmission_counter);
  plan (pp, rp);
  GNUNET_STATISTICS_update (GSF_stats,
                            gettext_noop
                            ("# query messages sent to other peers"), 1,
                            GNUNET_NO);
  return msize;
}
コード例 #20
0
ファイル: endian.c プロジェクト: idtek/knot
int main(int argc, char *argv[])
{
	plan(12);

	typedef union {
		uint16_t value;
		uint8_t  array[2];
	} trafo16_t;

	const uint16_t host16 = 0x0102;
	const trafo16_t be16 = { .array = { 0x01, 0x02 } };
	const trafo16_t le16 = { .array = { 0x02, 0x01 } };
	ok(htobe16(host16) == be16.value, "htobe16");
	ok(htole16(host16) == le16.value, "htole16");
	ok(be16toh(be16.value) == host16, "be16toh");
	ok(le16toh(le16.value) == host16, "le16toh");

	typedef union {
		uint32_t value;
		uint8_t  array[4];
	} trafo32_t;

	const uint32_t host32 = 0x01020304;
	const trafo32_t be32 = { .array = { 0x01, 0x02, 0x03, 0x04 } };
	const trafo32_t le32 = { .array = { 0x04, 0x03, 0x02, 0x01 } };
	ok(htobe32(host32) == be32.value, "htobe32");
	ok(htole32(host32) == le32.value, "htole32");
	ok(be32toh(be32.value) == host32, "be32toh");
	ok(le32toh(le32.value) == host32, "le32toh");

	typedef union {
		uint64_t value;
		uint8_t  array[8];
	} trafo64_t;

	const uint64_t host64 = 0x0102030405060708;
	const trafo64_t be64 = { .array = { 0x01, 0x02, 0x03, 0x04,
	                                    0x05, 0x06, 0x07, 0x08 } };
	const trafo64_t le64 = { .array = { 0x08, 0x07, 0x06, 0x05,
	                                    0x04, 0x03, 0x02, 0x01 } };
	ok(htobe64(host64) == be64.value, "htobe64");
	ok(htole64(host64) == le64.value, "htole64");
	ok(be64toh(be64.value) == host64, "be64toh");
	ok(le64toh(le64.value) == host64, "le64toh");

	return 0;
}
コード例 #21
0
void DivePlannerPointsModel::createPlan(bool replanCopy)
{
	// Ok, so, here the diveplan creates a dive
	char *cache = NULL;
	bool oldRecalc = setRecalc(false);
	removeDeco();
	createTemporaryPlan();
	setRecalc(oldRecalc);

	//TODO: C-based function here?
	bool did_deco = plan(&diveplan, &cache, isPlanner(), true);
	free(cache);
	if (!current_dive || displayed_dive.id != current_dive->id) {
		// we were planning a new dive, not re-planning an existing on
		record_dive(clone_dive(&displayed_dive));
	} else if (current_dive && displayed_dive.id == current_dive->id) {
		// we are replanning a dive - make sure changes are reflected
		// correctly in the dive structure and copy it back into the dive table
		displayed_dive.maxdepth.mm = 0;
		displayed_dive.dc.maxdepth.mm = 0;
		fixup_dive(&displayed_dive);
		if (replanCopy) {
			struct dive *copy = alloc_dive();
			copy_dive(current_dive, copy);
			copy->id = 0;
			copy->selected = false;
			copy->divetrip = NULL;
			if (current_dive->divetrip)
				add_dive_to_trip(copy, current_dive->divetrip);
			record_dive(copy);
			QString oldnotes(current_dive->notes);
			if (oldnotes.indexOf(QString(disclaimer)) >= 0)
				oldnotes.truncate(oldnotes.indexOf(QString(disclaimer)));
			if (did_deco)
				oldnotes.append(displayed_dive.notes);
			displayed_dive.notes = strdup(oldnotes.toUtf8().data());
		}
		copy_dive(&displayed_dive, current_dive);
	}
	mark_divelist_changed(true);

	// Remove and clean the diveplan, so we don't delete
	// the dive by mistake.
	free_dps(&diveplan);
	setPlanMode(NOTHING);
	planCreated();
}
コード例 #22
0
ファイル: source-ip-t.c プロジェクト: moretension/remctl
int
main(void)
{
    struct kerberos_config *config;
    const char *err;
    struct remctl *r;
    struct remctl_output *output;
    const char *command[] = { "test", "env", "REMOTE_ADDR", NULL };

    /* Set up Kerberos and remctld. */
    config = kerberos_setup(TAP_KRB_NEEDS_KEYTAB);
    remctld_start(config, "data/conf-simple", (char *) 0);

    plan(10);

    /* Successful connection to 127.0.0.1. */
    r = remctl_new();
    ok(r != NULL, "remctl_new");
    ok(remctl_set_source_ip(r, "127.0.0.1"), "remctl_set_source_ip");
    ok(remctl_open(r, "127.0.0.1", 14373, config->principal),
       "remctl_open to 127.0.0.1");
    ok(remctl_command(r, command), "remctl_command");
    output = remctl_output(r);
    ok(output != NULL, "remctl_output");
    if (output == NULL)
        ok_block(3, 0, "remctl_output failed");
    else {
        is_int(REMCTL_OUT_OUTPUT, output->type, "output token");
        ok(memcmp("127.0.0.1\n", output->data, strlen("127.0.0.1\n")) == 0,
           "correct IP address");
        is_int(strlen("127.0.0.1\n"), output->length, "correct length");
    }

    /* Failed connection to ::1. */
    ok(!remctl_open(r, "::1", 14373, config->principal), "remctl_open to ::1");
    err = remctl_error(r);
    diag("error: %s", err);
    ok(((strncmp("cannot connect to ::1 (port 14373): ", err,
                strlen("cannot connect to ::1 (port 14373): ")) == 0)
        || (strncmp("unknown host ::1: ", err,
                    strlen("unknown host ::1: ")) == 0)),
       "failed with correct error");

    remctl_close(r);
    return 0;
}
コード例 #23
0
ファイル: args-t.c プロジェクト: HenryJacques/pam-krb5
int
main(void)
{
    pam_handle_t *pamh;
    struct pam_conv conv = { NULL, NULL };
    struct pam_args *args;

    plan(12);

    if (pam_start("test", NULL, &conv, &pamh) != PAM_SUCCESS)
        sysbail("Fake PAM initialization failed");
    args = putil_args_new(pamh, 0);
    ok(args != NULL, "New args struct is not NULL");
    if (args == NULL)
        ok_block(7, 0, "...args struct is NULL");
    else {
        ok(args->pamh == pamh, "...and pamh is correct");
        ok(args->config == NULL, "...and config is NULL");
        ok(args->user == NULL, "...and user is NULL");
        is_int(args->debug, false, "...and debug is false");
        is_int(args->silent, false, "...and silent is false");
#ifdef HAVE_KRB5
        ok(args->ctx != NULL, "...and the Kerberos context is initialized");
        ok(args->realm == NULL, "...and realm is NULL");
#else
        skip_block(2, "Kerberos support not configured");
#endif
    }
    putil_args_free(args);
    ok(1, "Freeing the args struct works");

    args = putil_args_new(pamh, PAM_SILENT);
    ok(args != NULL, "New args struct with PAM_SILENT is not NULL");
    if (args == NULL)
        ok(0, "...args is NULL");
    else
        is_int(args->silent, true, "...and silent is true");
    putil_args_free(args);

    putil_args_free(NULL);
    ok(1, "Freeing a NULL args struct works");

    pam_end(pamh, 0);

    return 0;
}
コード例 #24
0
static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyModule(ExecState* state)
{
    VM& vm = state->vm();
    auto scope = DECLARE_THROW_SCOPE(vm);
    JSValue val = state->argument(0);

    // If the given bytes argument is not a BufferSource, a TypeError exception is thrown.
    JSArrayBuffer* arrayBuffer = val.getObject() ? jsDynamicCast<JSArrayBuffer*>(val.getObject()) : nullptr;
    JSArrayBufferView* arrayBufferView = val.getObject() ? jsDynamicCast<JSArrayBufferView*>(val.getObject()) : nullptr;
    if (!(arrayBuffer || arrayBufferView))
        return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral("first argument to WebAssembly.Module must be an ArrayBufferView or an ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(val))));

    if (arrayBufferView ? arrayBufferView->isNeutered() : arrayBuffer->impl()->isNeutered())
        return JSValue::encode(throwException(state, scope, createTypeError(state, ASCIILiteral("underlying TypedArray has been detatched from the ArrayBuffer"), defaultSourceAppender, runtimeTypeForValue(val))));

    size_t byteOffset = arrayBufferView ? arrayBufferView->byteOffset() : 0;
    size_t byteSize = arrayBufferView ? arrayBufferView->length() : arrayBuffer->impl()->byteLength();
    const auto* base = arrayBufferView ? static_cast<uint8_t*>(arrayBufferView->vector()) : static_cast<uint8_t*>(arrayBuffer->impl()->data());

    Wasm::Plan plan(&vm, base + byteOffset, byteSize);
    // On failure, a new WebAssembly.CompileError is thrown.
    plan.run();
    if (plan.failed())
        return JSValue::encode(throwException(state, scope, createWebAssemblyCompileError(state, plan.errorMessage())));

    // On success, a new WebAssembly.Module object is returned with [[Module]] set to the validated Ast.module.
    auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->jsCallee())->globalObject()->WebAssemblyModuleStructure());
    RETURN_IF_EXCEPTION(scope, { });

    // The export symbol table is the same for all Instances of a Module.
    SymbolTable* exportSymbolTable = SymbolTable::create(vm);
    for (auto& exp : plan.exports()) {
        auto offset = exportSymbolTable->takeNextScopeOffset(NoLockingNecessary);
        exportSymbolTable->set(NoLockingNecessary, exp.field.impl(), SymbolTableEntry(VarOffset(offset)));
    }

    // Only wasm-internal functions have a callee, stubs to JS do not.
    unsigned calleeCount = plan.internalFunctionCount();
    JSWebAssemblyModule* result = JSWebAssemblyModule::create(vm, structure, plan.takeModuleInformation(), plan.takeCallLinkInfos(), plan.takeWasmToJSStubs(), plan.takeFunctionIndexSpace(), exportSymbolTable, calleeCount);
    plan.initializeCallees(state->jsCallee()->globalObject(), 
        [&] (unsigned calleeIndex, JSWebAssemblyCallee* jsEntrypointCallee, JSWebAssemblyCallee* wasmEntrypointCallee) {
            result->setJSEntrypointCallee(vm, calleeIndex, jsEntrypointCallee);
            result->setWasmEntrypointCallee(vm, calleeIndex, wasmEntrypointCallee);
        });
    return JSValue::encode(result);
}
コード例 #25
0
int main(void){
    wchar_t dest[11];
    
    plan(31);

    ok(SUCCEEDED(StringCbPrintfExW(dest, 11 * sizeof(wchar_t),
                    NULL, NULL, 0, L"test")),
            "Print short string without any extended functionality.");
    is_wstring(L"test", dest,
            "Result of printing short string.");

    testDestEnd();
    testRemaining();
    testFlags();

    return 0;
}
コード例 #26
0
ファイル: copy.t.c プロジェクト: jajm/libobject
int main()
{
	object_t *object, *copy;

	plan(10);

	object = hash(
		"string", string("foo"),
		"real", real(4.2),
		"integer", integer(42),
		"boolean", boolean(true),
		"array", array(
			integer(1),
			integer(2),
			integer(3)
		)
	);

	copy = object_copy(object);

	hash_set(object, "string", string("bar"));
	ok(!strcmp("bar", string_to_c_str(hash_get(object, "string"))), "object[\"string\"] is \"bar\"");
	ok(!strcmp("foo", string_to_c_str(hash_get(copy, "string"))), "copy[\"string\"] is \"foo\"");

	hash_set(object, "real", real(3.4));
	ok(real_get(hash_get(object, "real")) == 3.4, "object[\"real\"] == 3.4");
	ok(real_get(hash_get(copy, "real")) == 4.2, "copy[\"real\"] == 4.2");

	hash_set(object, "integer", integer(34));
	ok(integer_get(hash_get(object, "integer")) == 34, "object[\"integer\"] == 34");
	ok(integer_get(hash_get(copy, "integer")) == 42, "copy[\"integer\"] == 42");

	hash_set(object, "boolean", boolean(false));
	ok(boolean_get(hash_get(object, "boolean")) == false, "object[\"boolean\"] is false");
	ok(boolean_get(hash_get(copy, "boolean")) == true, "copy[\"boolean\"] is true");

	array_splice(hash_get(object, "array"), 0, 3, NULL);
	ok(array_size(hash_get(object, "array")) == 0, "object[\"array\"] contains 0 elements");
	ok(array_size(hash_get(copy, "array")) == 3, "copy[\"array\"] contains 3 elements");

	object_free(copy);
	object_free(object);

	return 0;
}
コード例 #27
0
ファイル: dynstring-t.c プロジェクト: asmlib/mariadb-server
int main(void)
{
  plan(23);

  IF_WIN(skip_all("Test of POSIX shell escaping rules, not for CMD.EXE\n"), );

  ok(init_dynamic_string(&str1, NULL, 0, 32) == 0, "init");

  ok(dynstr_append_os_quoted(&str1, "test1", NULL) == 0, "append");
  check("'test1'");

  ok(dynstr_append_os_quoted(&str1, "con", "cat", NULL) == 0, "append");
  check("'concat'");

  ok(dynstr_append_os_quoted(&str1, "", NULL) == 0, "append");
  check("''");

  ok(dynstr_append_os_quoted(&str1, "space inside", NULL) == 0, "append");
  check("'space inside'");

  ok(dynstr_append_os_quoted(&str1, "single'quote", NULL) == 0, "append");
  check("'single'\"'\"'quote'");

  ok(dynstr_append_os_quoted(&str1, "many'single'quotes", NULL) == 0, "append");
  check("'many'\"'\"'single'\"'\"'quotes'");

  ok(dynstr_append_os_quoted(&str1, "'single quoted'", NULL) == 0, "append");
  check("''\"'\"'single quoted'\"'\"''");

  ok(dynstr_append_os_quoted(&str1, "double\"quote", NULL) == 0, "append");
  check("'double\"quote'");

  ok(dynstr_append_os_quoted(&str1, "mixed\"single'and\"double'quotes", NULL) == 0, "append");
  check("'mixed\"single'\"'\"'and\"double'\"'\"'quotes'");

  ok(dynstr_append_os_quoted(&str1, "back\\space", NULL) == 0, "append");
  check("'back\\space'");

  ok(dynstr_append_os_quoted(&str1, "backspace\\'and\\\"quote", NULL) == 0, "append");
  check("'backspace\\'\"'\"'and\\\"quote'");

  dynstr_free(&str1);

  return exit_status();
}
コード例 #28
0
ファイル: strlcpy-t.c プロジェクト: irush-cs/pam-krb5
int
main(void)
{
    char buffer[10];

    plan(23);

    is_int(3, test_strlcpy(buffer, "foo", sizeof(buffer)), "simple strlcpy");
    is_string("foo", buffer, "...result is correct");
    is_int(9, test_strlcpy(buffer, "hello wor", sizeof(buffer)),
           "strlcpy exact length of buffer");
    is_string("hello wor", buffer, "...result is correct");
    is_int(10, test_strlcpy(buffer, "world hell", sizeof(buffer)),
           "strlcpy one more than buffer length");
    is_string("world hel", buffer, "...result is correct");
    ok(buffer[9] == '\0', "...buffer is nul-terminated");
    is_int(11, test_strlcpy(buffer, "hello world", sizeof(buffer)),
           "strlcpy more than buffer length");
    is_string("hello wor", buffer, "...result is correct");
    ok(buffer[9] == '\0', "...buffer is nul-terminated");

    /* Make sure that with a size of 0, the destination isn't changed. */
    is_int(3, test_strlcpy(buffer, "foo", 0), "buffer unchanged if size 0");
    is_string("hello wor", buffer, "...contents still the same");

    /* Now play with empty strings. */
    is_int(0, test_strlcpy(buffer, "", 0), "copy empty string with size 0");
    is_string("hello wor", buffer, "...buffer unchanged");
    is_int(0, test_strlcpy(buffer, "", sizeof(buffer)),
           "copy empty string into full buffer");
    is_string("", buffer, "...buffer now empty string");
    is_int(3, test_strlcpy(buffer, "foo", 2),
           "copy string into buffer of size 2");
    is_string("f", buffer, "...got one character");
    ok(buffer[1] == '\0', "...buffer is nul-terminated");
    is_int(0, test_strlcpy(buffer, "", 1),
           "copy empty string into buffer of size 1");
    ok(buffer[0] == '\0', "...buffer is empty string");

    /* Finally, check using strlcpy as strlen. */
    is_int(3, test_strlcpy(NULL, "foo", 0), "use strlcpy as strlen");
    is_int(11, test_strlcpy(NULL, "hello world", 0), "...again");

    return 0;
}
コード例 #29
0
ファイル: client-t.c プロジェクト: moretension/remctl
int
main(void)
{
    /* Set up the plan. */
    plan(22);

    /* Test network_client_create. */
    test_create_ipv4(NULL);
    test_create_ipv4("127.0.0.1");

    /* Test network_connect with a timeout. */
    test_timeout_ipv4();

    /* Test network_read and network_write. */
    test_network_read();
    test_network_write();
    return 0;
}
コード例 #30
0
void do_tests()
{
    plan(4);

    bad= my_atomic_initialize();
    ok(!bad, "my_atomic_initialize() returned %d", bad);

    my_atomic_rwlock_init(&rwl);

    b32= c32= 0;
    test_concurrently("my_atomic_add32", test_atomic_add, THREADS, CYCLES);
    b32= c32= 0;
    test_concurrently("my_atomic_fas32", test_atomic_fas, THREADS, CYCLES);
    b32= c32= 0;
    test_concurrently("my_atomic_cas32", test_atomic_cas, THREADS, CYCLES);

    my_atomic_rwlock_destroy(&rwl);
}