diff --git a/0006-Adapt-to-bionic-libc-improve-lcov-coverage.patch b/0006-Adapt-to-bionic-libc-improve-lcov-coverage.patch new file mode 100644 index 0000000..8626af6 --- /dev/null +++ b/0006-Adapt-to-bionic-libc-improve-lcov-coverage.patch @@ -0,0 +1,98 @@ +From 88596185a48394d9aea122e80a6b6cf86ac216ba Mon Sep 17 00:00:00 2001 +From: chegJH +Date: Tue, 10 May 2022 18:06:53 +0800 +Subject: [PATCH] Adapt to bionic libc, improve lcov coverage + +Signed-off-by: chegJH +--- + src/utils/cutils/CMakeLists.txt | 4 ++++ + test/cutils/utils_pwgr/passwd_sample | 1 + + test/cutils/utils_pwgr/utils_pwgr_ut.cc | 24 ++++++++++++++++++++++++ + 3 files changed, 29 insertions(+) + +diff --git a/src/utils/cutils/CMakeLists.txt b/src/utils/cutils/CMakeLists.txt +index 0ecad671..30414d91 100644 +--- a/src/utils/cutils/CMakeLists.txt ++++ b/src/utils/cutils/CMakeLists.txt +@@ -2,6 +2,10 @@ + aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} local_cutils_srcs) + add_subdirectory(map) + ++if (NOT ANDROID) ++ list(REMOVE_ITEM local_cutils_srcs "${CMAKE_CURRENT_SOURCE_DIR}/utils_pwgr.c") ++endif() ++ + set(CUTILS_SRCS + ${local_cutils_srcs} + ${MAP_SRCS} +diff --git a/test/cutils/utils_pwgr/passwd_sample b/test/cutils/utils_pwgr/passwd_sample +index d4f3250d..76853454 100644 +--- a/test/cutils/utils_pwgr/passwd_sample ++++ b/test/cutils/utils_pwgr/passwd_sample +@@ -3,6 +3,7 @@ bin:x:1:1:bin:/bin:/sbin/nologin + bin:x:-1:1:bin:/bin:/sbin/nologin + uidonly:x:1::bin:/bin:/sbin/nologin + ::::1:1:bin:/bin:/sbin/nologin ++root:x: + + #npt:*:66:77::/etc/ntp:/sbin/nologin + npt:*:66:77::/etc/ntp:/sbin/nologin +diff --git a/test/cutils/utils_pwgr/utils_pwgr_ut.cc b/test/cutils/utils_pwgr/utils_pwgr_ut.cc +index 1a121f88..1ed8eaa1 100644 +--- a/test/cutils/utils_pwgr/utils_pwgr_ut.cc ++++ b/test/cutils/utils_pwgr/utils_pwgr_ut.cc +@@ -24,6 +24,7 @@ TEST(utils_pwgr, test_getpwent_r) + + struct passwd pw; + struct passwd *ppw = nullptr; ++ struct passwd *ppw_alter = &pw; + char buf[BUFSIZ]; + + std::vector> testcase = { +@@ -36,6 +37,17 @@ TEST(utils_pwgr, test_getpwent_r) + std::make_tuple("-npt", "*", 0, 0, "", "/etc/ntp", "/sbin/nologin") + }; + ++ ASSERT_EQ(util_getpwent_r(NULL, &pw, buf, sizeof(buf), &ppw), -1); ++ ASSERT_EQ(util_getpwent_r(f_pw, &pw, NULL, 0, &ppw), -1); ++ ASSERT_EQ(util_getpwent_r(f_pw, &pw, NULL, 1, &ppw), -1); ++ ASSERT_EQ(util_getpwent_r(f_pw, &pw, buf, sizeof(buf), &ppw_alter), -1); ++ ++ while (!feof(f_pw)) { ++ (void)getc(f_pw); ++ } ++ ASSERT_EQ(util_getpwent_r(f_pw, &pw, buf, sizeof(buf), &ppw), ENOENT); ++ rewind(f_pw); ++ + for (const auto &elem : testcase) { + ASSERT_EQ(util_getpwent_r(f_pw, &pw, buf, sizeof(buf), &ppw), 0); + ASSERT_STREQ(pw.pw_name, std::get<0>(elem).c_str()); +@@ -61,6 +73,7 @@ TEST(utils_pwgr, test_getgrent_r) + + struct group gr{0}; + struct group *pgr = nullptr; ++ struct group *pgr_alter = &gr; + char buf[BUFSIZ]; + size_t i = 0; + size_t j = 0; +@@ -80,6 +93,17 @@ TEST(utils_pwgr, test_getgrent_r) + std::make_tuple("adm", "x", 4), + }; + ++ ASSERT_EQ(util_getgrent_r(NULL, &gr, buf, sizeof(buf), &pgr), -1); ++ ASSERT_EQ(util_getgrent_r(f_gr, &gr, NULL, 0, &pgr), -1); ++ ASSERT_EQ(util_getgrent_r(f_gr, &gr, NULL, 1, &pgr), -1); ++ ASSERT_EQ(util_getgrent_r(f_gr, &gr, buf, sizeof(buf), &pgr_alter), -1); ++ ++ while (!feof(f_gr)) { ++ (void)getc(f_gr); ++ } ++ ASSERT_EQ(util_getgrent_r(f_gr, &gr, buf, sizeof(buf), &pgr), ENOENT); ++ rewind(f_gr); ++ + for (; i < string_list.size(); ++i) { + ASSERT_EQ(util_getgrent_r(f_gr, &gr, buf, sizeof(buf), &pgr), 0); + ASSERT_STREQ(gr.gr_name, std::get<0>(testcase[i]).c_str()); +-- +2.32.0 (Apple Git-132) + diff --git a/iSulad.spec b/iSulad.spec index 706bd16..d2e8648 100644 --- a/iSulad.spec +++ b/iSulad.spec @@ -1,5 +1,5 @@ %global _version 2.0.13 -%global _release 3 +%global _release 4 %global is_systemd 1 %global enable_shimv2 1 %global is_embedded 1 @@ -18,6 +18,7 @@ Patch0002: 0002-refactor-mount-parse-in-spec-module.patch Patch0003: 0003-support-isula-wait-even-if-it-s-not-oci-image.patch Patch0004: 0004-add-isula-import-restful-mode.patch Patch0005: 0005-Adapt-to-bionic-libc-parser-for-passwd-and-group-obj.patch +Patch0006: 0006-Adapt-to-bionic-libc-improve-lcov-coverage.patch %ifarch x86_64 aarch64 Provides: libhttpclient.so()(64bit) @@ -245,6 +246,12 @@ fi %endif %changelog +* Mon May 10 2022 hejunjie - 2.0.13-4 +- Type: enhancement +- ID: NA +- SUG: NA +- DESC: bionic adaptation, increase lcov coverage + * Mon May 5 2022 hejunjie - 2.0.13-3 - Type: enhancement - ID: NA