[SSSD] [PATCH 1/1] tests: Don't assume absolute test dir in test_io.c

Nikolai Kondrashov Nikolai.Kondrashov at redhat.com
Wed Apr 16 13:21:25 UTC 2014


On 04/16/2014 04:03 PM, Lukas Slebodnik wrote:
>>
>> Agreed.
>> However, the problem lies entirely in the test, and I'm trying to solve it.
>>
>> The test first changes into TEST_DIR, then tries to open TEST_DIR.
>> This wouldn't work with a relative path such as "test-dir", as there is not
>> likely to be "test-dir" within "test-dir".
>>
>> It also tries to create a temporary file in TEST_DIR, while already being in
>> TEST_DIR. This also doesn't work with "test-dir", for the same reason.
>
> test_io is simple unit test and it does not worth to refactor this test.

Sure, but I'm not suggesting we should refactor it. The proposed patch fixes
the problem in its entirety.

> It works if $TEST_DIR is created.

Not always. Not when the path is relative (and not "."). Please execute this
and see for yourself:

     mkdir test-dir
     ./configure --with-test-dir=test-dir
     make check

The test output will be something like this:

     [==========] Running 8 test(s).
     [ RUN      ] test_sss_open_cloexec_success
     mkstemp failed with path:'test-dir/test_io.eTfWX8' [No such file or directory]
     ret == -1
     src/tests/cmocka/test_io.c:59: error: Failure!
     [  FAILED  ] test_sss_open_cloexec_success
     [ RUN      ] test_sss_open_cloexec_fail
     [       OK ] test_sss_open_cloexec_fail
     Could not open directory:'test-dir' [No such file or directory]
     dirp
     src/tests/cmocka/test_io.c:72: error: Failure!
     [  FAILED  ] test_sss_openat_cloexec_success_setup_dirp
     [ RUN      ] test_sss_openat_cloexec_success
     11
     [  FAILED  ] test_sss_openat_cloexec_success
     Could not open directory:'test-dir' [No such file or directory]
     dirp
     src/tests/cmocka/test_io.c:72: error: Failure!
     [  FAILED  ] test_sss_openat_cloexec_fail_setup_dirp
     [ RUN      ] test_sss_openat_cloexec_fail


>> All of the above with TEST_DIR existing at the time of running the test.

> Please focus to writing new tests :-)

I will, when I have my functionality to implement, or will know enough of
one of others :)

> testing value of "--with-test-dir" can be done
> in macro WITH_TEST_DIR (file src/conf_macros.m4)
> It would be simple test and macro will not be very complicated after change.
>
> You can write warning or error AC_MSG_WARN, AC_MSG_ERROR.
> It would be good to test value before macro "AC_SUBST(TEST_DIR)"

Thanks, I'll think about doing this in a separate patch.

Sincerely,
Nick



More information about the sssd-devel mailing list