代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/dhcp 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From bd6db12aaeecbc4f76462b4016c7e74e43d532f3 Mon Sep 17 00:00:00 2001
From: zhangqiumiao <zhangqiumiao1@huawei.com>
Date: Tue, 10 Nov 2020 02:10:57 -0500
Subject: [PATCH] add a test case to parse code93 in option_unittest
---
common/tests/option_unittest.c | 70 ++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/common/tests/option_unittest.c b/common/tests/option_unittest.c
index cd52cfb..0bb6517 100644
--- a/common/tests/option_unittest.c
+++ b/common/tests/option_unittest.c
@@ -129,6 +129,75 @@ ATF_TC_BODY(pretty_print_option, tc)
}
}
+ATF_TC(parse_code93_option);
+
+ATF_TC_HEAD(parse_code93_option, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that code93 can be parsed.");
+}
+
+ATF_TC_BODY(parse_code93_option, tc)
+{
+ struct option *option;
+ unsigned code;
+ unsigned char bad_data[32*1024];
+ unsigned char good_data1[] = { 0,0 };
+ unsigned char good_data2[] = { 0,7 };
+ unsigned char good_data3[] = { 0,11 };
+ int emit_commas = 1;
+ int emit_quotes = 1;
+ const char *output_buf;
+
+ /* Initialize whole thing to non-printable chars */
+ memset(bad_data, 0x1f, sizeof(bad_data));
+
+ initialize_common_option_spaces();
+
+ /* We'll use pxe-system-type and it happens to be format Sa */
+ code = 93;
+ option = NULL;
+ if (!option_code_hash_lookup(&option, dhcp_universe.code_hash,
+ &code, 0, MDL)) {
+ atf_tc_fail("can't find option %d", code);
+ }
+
+ if (option == NULL) {
+ atf_tc_fail("option is NULL");
+ }
+
+ /* First we will try a good value we know should fit. */
+ output_buf = pretty_print_option (option, good_data1, sizeof(good_data1),
+ emit_commas, emit_quotes);
+
+ /* Make sure we get what we expect */
+ if (!output_buf || strcmp(output_buf, "0")) {
+ atf_tc_fail("pretty_print_option 1 did not return \"<error>\"");
+ }
+
+ output_buf = pretty_print_option (option, good_data2, sizeof(good_data3),
+ emit_commas, emit_quotes);
+ /* Make sure we get what we expect */
+ if (!output_buf || strcmp(output_buf, "7")) {
+ atf_tc_fail("pretty_print_option 2 did not return \"<error>\"");
+ }
+
+ output_buf = pretty_print_option (option, good_data3, sizeof(good_data3),
+ emit_commas, emit_quotes);
+ /* Make sure we get what we expect */
+ if (!output_buf || strcmp(output_buf, "11")) {
+ atf_tc_fail("pretty_print_option 3 did not return \"<error>\"");
+ }
+
+ /* Now we'll try a data value that's too large */
+ output_buf = pretty_print_option (option, bad_data, sizeof(bad_data),
+ emit_commas, emit_quotes);
+
+ /* Make sure we safely get an error */
+ if (!output_buf || strcmp(output_buf, "<error>")) {
+ atf_tc_fail("pretty_print_option did not return \"<error>\"");
+ }
+}
/* This macro defines main() method that will call specified
test cases. tp and simple_test_case names can be whatever you want
@@ -137,6 +206,7 @@ ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, option_refcnt);
ATF_TP_ADD_TC(tp, pretty_print_option);
+ ATF_TP_ADD_TC(tp, parse_code93_option);
return (atf_no_error());
}
--
2.19.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。