END_TEST START_TEST(test_ck_assert_str_ne) { const char *s = "test2"; const char *t = "test1"; ck_assert_str_ne(t, s); t = "test2"; ck_assert_str_ne(t, s); #define LINENO_ck_assert_str_ne _STR(__LINE__) }
END_TEST START_TEST (test_get_name_no_response) { char* response = "CMD\r\n"; read_message = response; read_message_length = 5; char name[20]; ck_assert(!config.connected); ck_assert_int_eq(at_commander_get_name(&config, name, sizeof(name)), 0); ck_assert(config.connected); ck_assert_str_ne(name, "FOO"); }
END_TEST START_TEST (test_get_device_id_bad_response) { char* response = "CMD\r\nERR"; read_message = response; read_message_length = 8; char device_id[20]; ck_assert(!config.connected); ck_assert(at_commander_get_device_id(&config, device_id, sizeof(device_id)) == -1); ck_assert(config.connected); ck_assert_str_ne(device_id, "00066646C2AF"); }
void verify_value_differs (struct json_object *jo, const char *key, const char *unexpected_value) { struct json_object *o; const char *value; o = json_object_object_get (jo, key); ck_assert (o != NULL); value = json_object_get_string (o); ck_assert_str_ne (value, unexpected_value); }
END_TEST START_TEST(test_mismatching_fingerprints) { int result = 0; ec_public_key *alice_identity_key = create_test_ec_public_key(global_context); ec_public_key *bob_identity_key = create_test_ec_public_key(global_context); ec_public_key *mitm_identity_key = create_test_ec_public_key(global_context); fingerprint_generator *generator = 0; fingerprint *alice_fingerprint = 0; fingerprint *bob_fingerprint = 0; result = fingerprint_generator_create(&generator, 1024, global_context); ck_assert_int_eq(result, 0); result = fingerprint_generator_create_for(generator, "+14152222222", alice_identity_key, "+14153333333", mitm_identity_key, &alice_fingerprint); ck_assert_int_eq(result, 0); result = fingerprint_generator_create_for(generator, "+14153333333", bob_identity_key, "+14152222222", alice_identity_key, &bob_fingerprint); ck_assert_int_eq(result, 0); displayable_fingerprint *alice_displayable = fingerprint_get_displayable(alice_fingerprint); displayable_fingerprint *bob_displayable = fingerprint_get_displayable(bob_fingerprint); ck_assert_str_ne( displayable_fingerprint_text(alice_displayable), displayable_fingerprint_text(bob_displayable)); scannable_fingerprint *alice_scannable = fingerprint_get_scannable(alice_fingerprint); scannable_fingerprint *bob_scannable = fingerprint_get_scannable(bob_fingerprint); ck_assert_int_ne(scannable_fingerprint_compare(alice_scannable, bob_scannable), 1); ck_assert_int_ne(scannable_fingerprint_compare(bob_scannable, alice_scannable), 1); /* Cleanup */ fingerprint_generator_free(generator); SIGNAL_UNREF(alice_identity_key); SIGNAL_UNREF(bob_identity_key); SIGNAL_UNREF(mitm_identity_key); SIGNAL_UNREF(alice_fingerprint); SIGNAL_UNREF(bob_fingerprint); }
static void test_bt_machine_unique_pattern_name (BT_TEST_ARGS) { BT_TEST_START; GST_INFO ("-- arrange --"); BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "gen", "buzztrax-test-poly-source", 1L, NULL)); BtPattern *pattern = bt_pattern_new (song, "pattern-name", 8L, machine); GST_INFO ("-- act --"); gchar *pattern_name = bt_machine_get_unique_pattern_name (machine); GST_INFO ("-- assert --"); ck_assert_str_ne (pattern_name, "pattern-name"); GST_INFO ("-- cleanup --"); g_free (pattern_name); g_object_unref (pattern); BT_TEST_END; }
/* * In this test case we check the _unique_id function. */ static void test_bt_setup_unique_machine_id1 (BT_TEST_ARGS) { BT_TEST_START; GST_INFO ("-- arrange --"); BtSetup *setup = BT_SETUP (check_gobject_get_object_property (song, "setup")); bt_source_machine_new (song, "src", "buzztrax-test-mono-source", 0, NULL); GST_INFO ("-- act --"); gchar *id = bt_setup_get_unique_machine_id (setup, "src"); GST_INFO ("-- assert --"); fail_unless (id != NULL, NULL); ck_assert_gobject_eq_and_unref (bt_setup_get_machine_by_id (setup, id), NULL); ck_assert_str_ne (id, "src"); GST_INFO ("-- cleanup --"); g_free (id); g_object_unref (setup); BT_TEST_END; }
END_TEST START_TEST(test_mg_server_and_client_tls) { #ifndef NO_SSL struct mg_context *ctx; int ports_cnt; struct mg_server_ports ports[16]; struct mg_callbacks callbacks; char errmsg[256]; struct mg_connection *client_conn; char client_err[256]; const struct mg_request_info *client_ri; int client_res; struct mg_client_options client_options; const char *OPTIONS[32]; /* initializer list here is rejected by CI test */ int opt_idx = 0; char server_cert[256]; char client_cert[256]; const char *res_dir = locate_resources(); ck_assert(res_dir != NULL); strcpy(server_cert, res_dir); strcpy(client_cert, res_dir); #ifdef _WIN32 strcat(server_cert, "cert\\server.pem"); strcat(client_cert, "cert\\client.pem"); #else strcat(server_cert, "cert/server.pem"); strcat(client_cert, "cert/client.pem"); #endif memset((void *)OPTIONS, 0, sizeof(OPTIONS)); #if !defined(NO_FILES) OPTIONS[opt_idx++] = "document_root"; OPTIONS[opt_idx++] = "."; #endif OPTIONS[opt_idx++] = "listening_ports"; OPTIONS[opt_idx++] = "8080r,8443s"; OPTIONS[opt_idx++] = "ssl_certificate"; OPTIONS[opt_idx++] = server_cert; OPTIONS[opt_idx++] = "ssl_verify_peer"; OPTIONS[opt_idx++] = "yes"; OPTIONS[opt_idx++] = "ssl_ca_file"; OPTIONS[opt_idx++] = client_cert; ck_assert_int_le(opt_idx, (int)(sizeof(OPTIONS) / sizeof(OPTIONS[0]))); ck_assert(OPTIONS[sizeof(OPTIONS) / sizeof(OPTIONS[0]) - 1] == NULL); ck_assert(OPTIONS[sizeof(OPTIONS) / sizeof(OPTIONS[0]) - 2] == NULL); memset(ports, 0, sizeof(ports)); memset(&callbacks, 0, sizeof(callbacks)); memset(errmsg, 0, sizeof(errmsg)); callbacks.log_message = log_msg_func; ctx = mg_start(&callbacks, (void *)errmsg, OPTIONS); mark_point(); test_sleep(1); ck_assert_str_eq(errmsg, ""); ck_assert(ctx != NULL); ports_cnt = mg_get_server_ports(ctx, 16, ports); ck_assert_int_eq(ports_cnt, 2); ck_assert_int_eq(ports[0].protocol, 1); ck_assert_int_eq(ports[0].port, 8080); ck_assert_int_eq(ports[0].is_ssl, 0); ck_assert_int_eq(ports[0].is_redirect, 1); ck_assert_int_eq(ports[1].protocol, 1); ck_assert_int_eq(ports[1].port, 8443); ck_assert_int_eq(ports[1].is_ssl, 1); ck_assert_int_eq(ports[1].is_redirect, 0); ck_assert_int_eq(ports[2].protocol, 0); ck_assert_int_eq(ports[2].port, 0); ck_assert_int_eq(ports[2].is_ssl, 0); ck_assert_int_eq(ports[2].is_redirect, 0); test_sleep(1); mark_point(); memset(client_err, 0, sizeof(client_err)); client_conn = mg_connect_client("127.0.0.1", 8443, 1, client_err, sizeof(client_err)); ck_assert(client_conn == NULL); ck_assert_str_ne(client_err, ""); memset(client_err, 0, sizeof(client_err)); memset(&client_options, 0, sizeof(client_options)); client_options.host = "127.0.0.1"; client_options.port = 8443; client_options.client_cert = client_cert; client_options.server_cert = server_cert; client_conn = mg_connect_client_secure(&client_options, client_err, sizeof(client_err)); ck_assert(client_conn != NULL); ck_assert_str_eq(client_err, ""); mg_printf(client_conn, "GET / HTTP/1.0\r\n\r\n"); client_res = mg_get_response(client_conn, client_err, sizeof(client_err), 10000); ck_assert_int_ge(client_res, 0); ck_assert_str_eq(client_err, ""); client_ri = mg_get_request_info(client_conn); ck_assert(client_ri != NULL); #if defined(NO_FILES) ck_assert_str_eq(client_ri->uri, "404"); #else ck_assert_str_eq(client_ri->uri, "200"); /* TODO: ck_assert_str_eq(client_ri->request_method, "HTTP/1.0"); */ client_res = (int)mg_read(client_conn, client_err, sizeof(client_err)); ck_assert_int_gt(client_res, 0); ck_assert_int_le(client_res, sizeof(client_err)); #endif mg_close_connection(client_conn); /* TODO: A client API using a client certificate is missing */ mark_point(); test_sleep(1); mark_point(); mg_stop(ctx); #endif }
END_TEST START_TEST(path_seat_change) { struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; struct libinput_event *event; struct libinput_device *device; struct libinput_seat *seat1, *seat2; const char *seat1_name; const char *seat2_name = "new seat"; int rc; libinput_dispatch(li); event = libinput_get_event(li); ck_assert_int_eq(libinput_event_get_type(event), LIBINPUT_EVENT_DEVICE_ADDED); device = libinput_event_get_device(event); libinput_device_ref(device); seat1 = libinput_device_get_seat(device); libinput_seat_ref(seat1); seat1_name = libinput_seat_get_logical_name(seat1); libinput_event_destroy(event); litest_drain_events(li); rc = libinput_device_set_seat_logical_name(device, seat2_name); ck_assert_int_eq(rc, 0); libinput_dispatch(li); event = libinput_get_event(li); ck_assert(event != NULL); ck_assert_int_eq(libinput_event_get_type(event), LIBINPUT_EVENT_DEVICE_REMOVED); ck_assert(libinput_event_get_device(event) == device); libinput_event_destroy(event); event = libinput_get_event(li); ck_assert(event != NULL); ck_assert_int_eq(libinput_event_get_type(event), LIBINPUT_EVENT_DEVICE_ADDED); ck_assert(libinput_event_get_device(event) != device); libinput_device_unref(device); device = libinput_event_get_device(event); seat2 = libinput_device_get_seat(device); ck_assert_str_ne(libinput_seat_get_logical_name(seat2), seat1_name); ck_assert_str_eq(libinput_seat_get_logical_name(seat2), seat2_name); libinput_event_destroy(event); libinput_seat_unref(seat1); /* litest: swap the new device in, so cleanup works */ libinput_device_unref(dev->libinput_device); libinput_device_ref(device); dev->libinput_device = device; }