diff options
author | Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com> | 2020-04-24 15:35:49 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2020-07-06 10:04:07 +0900 |
commit | 3dca373d843213f03c95df56e36b16d6b83fd58f (patch) | |
tree | 182e6b0cca5555d748453ba13c798bd629e0d13c | |
parent | b788c0350858a569297a5916e72432cf32731918 (diff) | |
download | DLT-daemon-3dca373d843213f03c95df56e36b16d6b83fd58f.tar.gz |
Unittest for new api
Add two new testcases in tests/gtest_dlt_common.cpp
for dlt_file_quick_parsing()
Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
-rw-r--r-- | tests/gtest_dlt_common.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/tests/gtest_dlt_common.cpp b/tests/gtest_dlt_common.cpp index 04fdbc6..adbc87d 100644 --- a/tests/gtest_dlt_common.cpp +++ b/tests/gtest_dlt_common.cpp @@ -1623,6 +1623,59 @@ TEST(t_dlt_file_open, nullpointer) +/* Begin Method: dlt_common::dlt_file_quick_parsing */ +TEST(t_dlt_file_quick_parsing, normal) +{ + DltFile file; + /* Get PWD so file can be used*/ + char pwd[100]; + char openfile[114]; + char output[128] = "/tmp/output_testfile.txt"; + + /* ignore returned value from getcwd */ + if (getcwd(pwd, 100) == NULL) {} + + sprintf(openfile, "%s/testfile.dlt", pwd); + /*---------------------------------------*/ + + /* Normal Use-Case, expected 0 */ + EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); + EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); + EXPECT_LE(DLT_RETURN_OK, dlt_file_quick_parsing(&file, output, DLT_OUTPUT_ASCII, 0)); + EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); + unlink(output); +} + +TEST(t_dlt_file_quick_parsing, abnormal) +{ + DltFile file; + /* Get PWD so file can be used*/ + char pwd[100]; + char openfile[114]; + char output[128] = "/tmp/output_testfile.txt"; + + /* ignore returned value from getcwd */ + if (getcwd(pwd, 100) == NULL) {} + + sprintf(openfile, "%s/testfile.dlt", pwd); + /*---------------------------------------*/ + + /* Abnormal Use-Case, expected DLT_RETURN_WRONG_PARAMETER (-5) */ + EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); + EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); + EXPECT_GE(DLT_RETURN_WRONG_PARAMETER, dlt_file_quick_parsing(&file, NULL, DLT_OUTPUT_ASCII, 0)); + EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); + + EXPECT_LE(DLT_RETURN_OK, dlt_file_init(&file, 0)); + EXPECT_LE(DLT_RETURN_OK, dlt_file_open(&file, openfile, 0)); + EXPECT_GE(DLT_RETURN_WRONG_PARAMETER, dlt_file_quick_parsing(NULL, output, DLT_OUTPUT_ASCII, 0)); + EXPECT_LE(DLT_RETURN_OK, dlt_file_free(&file, 0)); +} +/* End Method: dlt_common::dlt_file_quick_parsing */ + + + + /* Begin Method: dlt_common::dlt_message_print_ascii*/ TEST(t_dlt_message_print_ascii, normal) { @@ -3129,7 +3182,8 @@ TEST(t_dlt_message_payload, abnormal) /* Get PWD so file and filter can be used*/ char pwd[100]; - getcwd(pwd, 100); + if (getcwd(pwd, 100) == NULL) {} + char openfile[114]; sprintf(openfile, "%s/testfile.dlt", pwd); /*---------------------------------------*/ |