Your message dated Fri, 06 Jan 2023 17:51:50 +0000
with message-id <[email protected]>
and subject line Bug#1004191: fixed in libyang2 2.1.4-1
has caused the Debian Bug report #1004191,
regarding libyang2: enable build time tests
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1004191: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004191
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: libyang2
Version: 2.0.112-6
Severity: normal

Dear Maintainer,

libyang2 has a test suite that can run at build time, but it's
disabled by default in release builds. From upstream's README[1]:
```

The tests are by default built in the Debug build mode by running

$ make

In case of the Release mode, the tests are not built by default (it
requires additional dependency), but they can be enabled via cmake
option:

$ cmake -DENABLE_TESTS=ON ..
```

This is the diff for debian/rules to enable the tests with a release build:

--- a/debian/rules
+++ b/debian/rules
@@ -9,4 +9,5 @@ include /usr/share/dpkg/default.mk

 override_dh_auto_configure:
        dh_auto_configure -- \
-               -DCMAKE_BUILD_TYPE:String="Release"
+               -DCMAKE_BUILD_TYPE:String="Release" \
+               -DENABLE_TESTS=ON

Unfortunately, at least on Ubuntu, there were a couple of test
failures[2], which upstream promptly fixed[3]. I'm attaching the patch
I'm using in Ubuntu for that.

Thanks!



1. https://github.com/CESNET/libyang/blob/master/README.md
2. https://github.com/CESNET/libyang/issues/1773
3. 
https://github.com/CESNET/libyang/commit/de2e8b272b8238258f36c42386f3f2c9806026fd
Description: use test files instead of __FILE__
Author: Michal Vasko <[email protected]>
Origin: backport, https://github.com/CESNET/libyang/commit/de2e8b272b8238258f36c42386f3f2c9806026fd
Bug: https://github.com/CESNET/libyang/issues/1773
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libyang2/+bug/1958385
Last-Update: 2022-01-20
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/tests/utests/basic/test_context.c
+++ b/tests/utests/basic/test_context.c
@@ -38,9 +38,6 @@
     /* readable and executable, but not a directory */
     assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_BIN "/utest_context"));
     CHECK_LOG_CTX("Given search directory \""TESTS_BIN "/utest_context\" is not a directory.", NULL);
-    /* not executable */
-    assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(UTEST_LYCTX, __FILE__));
-    CHECK_LOG_CTX("Unable to fully access search directory \""__FILE__ "\" (Permission denied).", NULL);
     /* not existing */
     assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(UTEST_LYCTX, "/nonexistingfile"));
     CHECK_LOG_CTX("Unable to use search directory \"/nonexistingfile\" (No such file or directory).", NULL);
--- a/tests/utests/basic/test_inout.c
+++ b/tests/utests/basic/test_inout.c
@@ -26,6 +26,59 @@
 #include "log.h"
 #include "out.h"
 
+
+#define TEST_INPUT_FILE TESTS_BIN "/libyang_test_input"
+#define TEST_OUTPUT_FILE TESTS_BIN "/libyang_test_output"
+#define TEST_OUTPUT_FILE2 TESTS_BIN "/libyang_test_output2"
+
+static int
+setup_files(void **state)
+{
+    int fd;
+
+    UTEST_SETUP;
+
+    /* create input */
+    fd = open(TEST_INPUT_FILE, O_CREAT | O_WRONLY, 00600);
+    if (fd == -1) {
+        return 1;
+    }
+
+    /* write something */
+    if (write(fd, "data", 4) != 4) {
+        return 1;
+    }
+    close(fd);
+
+    /* create output */
+    fd = open(TEST_OUTPUT_FILE, O_CREAT | O_RDONLY, 00600);
+    if (fd == -1) {
+        return 1;
+    }
+    close(fd);
+
+    /* create output2 */
+    fd = open(TEST_OUTPUT_FILE2, O_CREAT | O_RDONLY, 00600);
+    if (fd == -1) {
+        return 1;
+    }
+    close(fd);
+
+    return 0;
+}
+
+static int
+teardown_files(void **state)
+{
+    unlink(TEST_INPUT_FILE);
+    unlink(TEST_OUTPUT_FILE);
+    unlink(TEST_OUTPUT_FILE2);
+
+    UTEST_TEARDOWN;
+    return 0;
+}
+
+
 static void
 test_input_mem(void **UNUSED(state))
 {
@@ -54,8 +107,8 @@
     assert_int_equal(LY_EINVAL, ly_in_new_fd(-1, NULL));
     assert_int_equal(-1, ly_in_fd(NULL, -1));
 
-    assert_int_not_equal(-1, fd1 = open(__FILE__, O_RDONLY));
-    assert_int_not_equal(-1, fd2 = open(__FILE__, O_RDONLY));
+    assert_int_not_equal(-1, fd1 = open(TEST_INPUT_FILE, O_RDONLY));
+    assert_int_not_equal(-1, fd2 = open(TEST_INPUT_FILE, O_RDONLY));
 
     assert_int_equal(LY_EINVAL, ly_in_new_fd(fd1, NULL));
 
@@ -83,8 +136,8 @@
     assert_int_equal(LY_EINVAL, ly_in_new_file(NULL, NULL));
     assert_null(ly_in_file(NULL, NULL));
 
-    assert_int_not_equal(-1, f1 = fopen(__FILE__, "r"));
-    assert_int_not_equal(-1, f2 = fopen(__FILE__, "r"));
+    assert_non_null(f1 = fopen(TEST_INPUT_FILE, "r"));
+    assert_non_null(f2 = fopen(TEST_INPUT_FILE, "r"));
 
     assert_int_equal(LY_EINVAL, ly_in_new_file(f1, NULL));
 
@@ -104,7 +157,7 @@
 test_input_filepath(void **UNUSED(state))
 {
     struct ly_in *in = NULL;
-    const char *path1 = __FILE__, *path2 = __FILE__;
+    const char *path1 = TEST_INPUT_FILE, *path2 = TEST_INPUT_FILE;
 
     assert_int_equal(LY_EINVAL, ly_in_new_filepath(NULL, 0, NULL));
     assert_int_equal(LY_EINVAL, ly_in_new_filepath(path1, 0, NULL));
@@ -154,10 +207,9 @@
     struct ly_out *out = NULL;
     int fd1, fd2;
     char buf[31] = {0};
-    const char *filepath = "/tmp/libyang_test_output";
 
-    assert_int_not_equal(-1, fd1 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
-    assert_int_not_equal(-1, fd2 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
+    assert_int_not_equal(-1, fd1 = open(TEST_OUTPUT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
+    assert_int_not_equal(-1, fd2 = open(TEST_OUTPUT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
 
     /* manipulate with the handler */
     assert_int_equal(LY_SUCCESS, ly_out_new_fd(fd1, &out));
@@ -171,8 +223,8 @@
     ly_out_free(out, NULL, 1);
 
     /* writing data */
-    assert_int_not_equal(-1, fd1 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
-    assert_int_not_equal(-1, fd2 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
+    assert_int_not_equal(-1, fd1 = open(TEST_OUTPUT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
+    assert_int_not_equal(-1, fd2 = open(TEST_OUTPUT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
     /* truncate file to start with no data */
     assert_int_equal(0, ftruncate(fd1, 0));
 
@@ -201,10 +253,9 @@
     struct ly_out *out = NULL;
     FILE *f1, *f2;
     char buf[31] = {0};
-    const char *filepath = "/tmp/libyang_test_output";
 
-    assert_int_not_equal(-1, f1 = fopen(filepath, "w"));
-    assert_int_not_equal(-1, f2 = fopen(filepath, "w"));
+    assert_non_null(f1 = fopen(TEST_OUTPUT_FILE, "w"));
+    assert_non_null(f2 = fopen(TEST_OUTPUT_FILE, "w"));
 
     /* manipulate with the handler */
     assert_int_equal(LY_SUCCESS, ly_out_new_file(f1, &out));
@@ -218,8 +269,8 @@
     ly_out_free(out, NULL, 1);
 
     /* writing data */
-    assert_int_not_equal(-1, f1 = fopen(filepath, "w"));
-    assert_int_not_equal(-1, f2 = fopen(filepath, "r"));
+    assert_non_null(f1 = fopen(TEST_OUTPUT_FILE, "w"));
+    assert_non_null(f2 = fopen(TEST_OUTPUT_FILE, "r"));
 
     assert_int_equal(LY_SUCCESS, ly_out_new_file(f1, &out));
     assert_int_equal(LY_SUCCESS, ly_print(out, "test %s", "print"));
@@ -246,8 +297,8 @@
     struct ly_out *out = NULL;
     FILE *f1;
     char buf[31] = {0};
-    const char *fp1 = "/tmp/libyang_test_output";
-    const char *fp2 = "/tmp/libyang_test_output2";
+    const char *fp1 = TEST_OUTPUT_FILE;
+    const char *fp2 = TEST_OUTPUT_FILE2;
 
     /* manipulate with the handler */
     assert_int_equal(LY_SUCCESS, ly_out_new_filepath(fp1, &out));
@@ -260,7 +311,7 @@
     ly_out_free(out, NULL, 1);
 
     /* writing data */
-    assert_int_not_equal(-1, f1 = fopen(fp1, "r"));
+    assert_non_null(f1 = fopen(fp1, "r"));
 
     assert_int_equal(LY_SUCCESS, ly_out_new_filepath(fp1, &out));
     assert_int_equal(LY_SUCCESS, ly_print(out, "test %s", "print"));
@@ -299,10 +350,9 @@
     struct ly_out *out = NULL;
     int fd1, fd2;
     char buf[31] = {0};
-    const char *filepath = "/tmp/libyang_test_output";
 
-    assert_int_not_equal(-1, fd1 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
-    assert_int_not_equal(-1, fd2 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
+    assert_int_not_equal(-1, fd1 = open(TEST_OUTPUT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
+    assert_int_not_equal(-1, fd2 = open(TEST_OUTPUT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
 
     /* manipulate with the handler */
     assert_int_equal(LY_SUCCESS, ly_out_new_clb(write_clb, (void *)(intptr_t)fd1, &out));
@@ -317,8 +367,8 @@
     ly_out_free(out, close_clb, 0);
 
     /* writing data */
-    assert_int_not_equal(-1, fd1 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
-    assert_int_not_equal(-1, fd2 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
+    assert_int_not_equal(-1, fd1 = open(TEST_OUTPUT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
+    assert_int_not_equal(-1, fd2 = open(TEST_OUTPUT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
     /* truncate file to start with no data */
     assert_int_equal(0, ftruncate(fd1, 0));
 
@@ -337,14 +387,14 @@
 {
     const struct CMUnitTest tests[] = {
         UTEST(test_input_mem),
-        UTEST(test_input_fd),
-        UTEST(test_input_file),
-        UTEST(test_input_filepath),
+        UTEST(test_input_fd, setup_files, teardown_files),
+        UTEST(test_input_file, setup_files, teardown_files),
+        UTEST(test_input_filepath, setup_files, teardown_files),
         UTEST(test_output_mem),
-        UTEST(test_output_fd),
-        UTEST(test_output_file),
-        UTEST(test_output_filepath),
-        UTEST(test_output_clb),
+        UTEST(test_output_fd, setup_files, teardown_files),
+        UTEST(test_output_file, setup_files, teardown_files),
+        UTEST(test_output_filepath, setup_files, teardown_files),
+        UTEST(test_output_clb, setup_files, teardown_files),
     };
 
     return cmocka_run_group_tests(tests, NULL, NULL);

--- End Message ---
--- Begin Message ---
Source: libyang2
Source-Version: 2.1.4-1
Done: Marco d'Itri <[email protected]>

We believe that the bug you reported is fixed in the latest version of
libyang2, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Marco d'Itri <[email protected]> (supplier of updated libyang2 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Fri, 06 Jan 2023 18:40:33 +0100
Source: libyang2
Architecture: source
Version: 2.1.4-1
Distribution: unstable
Urgency: medium
Maintainer: Ondřej Surý <[email protected]>
Changed-By: Marco d'Itri <[email protected]>
Closes: 1004191 1023794
Changes:
 libyang2 (2.1.4-1) unstable; urgency=medium
 .
   * Non-maintainer upload.
   * New upstream release. (Closes: #1023794)
   * Enable the build time tests. (Closes: #1004191)
Checksums-Sha1:
 a0bd28a178f7b74d9a0c023d7f699591e8b3603a 1521 libyang2_2.1.4-1.dsc
 785dc102773cb628be2f2d0d3e9a82a076d37785 804852 libyang2_2.1.4.orig.tar.xz
 4df00321b67f22745d0a12704fe4834b52e57768 11684 libyang2_2.1.4-1.debian.tar.xz
 c09dbcc40d038f76db7c9ce53b71debb4f21b4bd 7663 libyang2_2.1.4-1_amd64.buildinfo
Checksums-Sha256:
 6daac88ef84eeecdde37d01fd7b1fee7318d1054f753c90962aa899507daecaf 1521 
libyang2_2.1.4-1.dsc
 fbe2f3f57319534c3989e476d04a20e7e6dff8eaabd50d0625aafb95e620a114 804852 
libyang2_2.1.4.orig.tar.xz
 b1f016536729b619854b9980ba9afbe19654c392da048854f21fb737ee523e92 11684 
libyang2_2.1.4-1.debian.tar.xz
 db1a70d3d1851da88433c15021e9a9ad3f23dcce6ea4e0cfab7de098f383a07b 7663 
libyang2_2.1.4-1_amd64.buildinfo
Files:
 368ae0b3c2f651adea09575b94a2a776 1521 libs optional libyang2_2.1.4-1.dsc
 5d294818eebdd0d57cee536e36f1b724 804852 libs optional 
libyang2_2.1.4.orig.tar.xz
 69704bfc342713c8c5cd8a1d02aa2b08 11684 libs optional 
libyang2_2.1.4-1.debian.tar.xz
 74e840d30f44f0cc60a0e3890c1d0b58 7663 libs optional 
libyang2_2.1.4-1_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iHUEARYIAB0WIQQnKUXNg20437dCfobLPsM64d7XgQUCY7hd7wAKCRDLPsM64d7X
gasaAQDePQm54sXLDUVnDtG7WlawSOqXqVUd/TMZTOi1cAD8WwD/R3aJw8yJK5Pg
Zx3GgmVv+LSnCly5LZqHeCujUkdtQQs=
=BieY
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to