aboutgitcodelistschat:MatrixIRC
path: root/tests
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-05-09 16:28:58 +0200
committerAlice Frosi <afrosi@redhat.com>2023-05-10 13:47:04 +0200
commitb2aed1dc699adbac63bd35ffb5b014384a58fb94 (patch)
treefa0cce450cd76cdce4bd723ec110e4809c4bb888 /tests
parent92afac2a0ca640f19d39da6e7e82e1acb93e2024 (diff)
downloadseitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar
seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.gz
seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.bz2
seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.lz
seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.xz
seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.tar.zst
seitan-b2aed1dc699adbac63bd35ffb5b014384a58fb94.zip
seitan: add check for limits to op_cmp
Adding the offset limits checks and unit tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_errors.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/unit/test_errors.c b/tests/unit/test_errors.c
index ca6fcb0..06bae12 100644
--- a/tests/unit/test_errors.c
+++ b/tests/unit/test_errors.c
@@ -83,10 +83,33 @@ START_TEST(test_read_op_return)
ck_assert_int_eq(eval(&gluten, ops, &req, notifyfd), -1);
}
+static struct op_cmp test_cmp_data[] = {
+ { { OFFSET_DATA, DATA_SIZE }, { OFFSET_DATA, 0 }, 1, CMP_EQ, 1 },
+ { { OFFSET_DATA, 0 }, { OFFSET_DATA, DATA_SIZE }, 1, CMP_EQ, 1 },
+ { { OFFSET_DATA, DATA_SIZE - 1 }, { OFFSET_DATA, 0 }, 10, CMP_EQ, 1 },
+ { { OFFSET_DATA, 0 }, { OFFSET_DATA, DATA_SIZE - 1 }, 10, CMP_EQ, 1 },
+};
+
+START_TEST(test_op_cmp)
+{
+ struct op ops[2];
+
+ ops[0].type = OP_CMP;
+ ops[0].op.cmp.x.offset = test_cmp_data[_i].x.offset;
+ ops[0].op.cmp.x.type = test_cmp_data[_i].x.type;
+ ops[0].op.cmp.y.offset = test_cmp_data[_i].y.offset;
+ ops[0].op.cmp.y.type = test_cmp_data[_i].y.type;
+ ops[0].op.cmp.size = test_cmp_data[_i].size;
+ ops[0].op.cmp.jmp = test_cmp_data[_i].jmp;
+ ops[1].type = OP_END;
+
+ ck_assert_int_eq(eval(&gluten, ops, &req, notifyfd), -1);
+}
+
Suite *error_suite(void)
{
Suite *s;
- TCase *bounds, *gwrite, *gread;
+ TCase *bounds, *gwrite, *gread, *gcmp;
s = suite_create("Error handling");
@@ -109,6 +132,12 @@ Suite *error_suite(void)
sizeof(test_max_size_read_data[0]));
suite_add_tcase(s, gread);
+ gcmp = tcase_create("compare gluten");
+ tcase_add_checked_fixture(gcmp, setup_error_check, teardown);
+ tcase_add_loop_test(gcmp, test_op_cmp, 0,
+ sizeof(test_cmp_data) / sizeof(test_cmp_data[0]));
+ suite_add_tcase(s, gcmp);
+
return s;
}