Add unittest
authorRoy7Kim <myoungwoon.kim@samsung.com>
Wed, 10 May 2023 03:10:09 +0000 (12:10 +0900)
committerRoy7Kim <myoungwoon.kim@samsung.com>
Wed, 10 May 2023 03:10:23 +0000 (12:10 +0900)
[   55s] + for unit_test in '${unit_test_list}'
[   55s] + ./namedtempfile
[   55s]
[   55s] running 24 tests
[   55s] test temp_path_from_argument_types ... ok
[   55s] test test_append ... ok
[   55s] test temp_path_from_existing ... ok
[   55s] test test_basic ... ok
[   55s] test test_change_dir ... ok
[   55s] test test_customnamed ... ok
[   55s] test test_deleted ... ok
[   55s] test test_from_parts ... ok
[   55s] test test_immut ... ok
[   55s] test test_into_file ... ok
[   55s] test test_into_parts ... ok
[   55s] test test_keep ... ok
[   55s] test test_make ... ok
[   55s] test test_make_fnmut ... ok
[   55s] test test_make_in ... ok
[   55s] test test_make_uds ... ok
[   55s] test test_persist ... ok
[   55s] test test_reopen ... ok
[   55s] test test_persist_noclobber ... ok
[   55s] test test_temppath ... ok
[   55s] test test_temppath_persist ... ok
[   55s] test test_write_after_close ... ok
[   55s] test test_temppath_persist_noclobber ... ok
[   55s] test test_make_uds_conflict ... ok
[   55s]
[   55s] test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.06s
[   55s]
[   55s] + for unit_test in '${unit_test_list}'
[   55s] + ./spooled
[   55s]
[   55s] running 16 tests
[   55s] test test_explicit_rollover ... ok
[   55s] test test_automatic_rollover ... ok
[   55s] test test_overwrite_and_extend_buffer ... ok
[   55s] test test_overwrite_and_extend_rollover ... ok
[   55s] test test_overwrite_middle_of_buffer ... ok
[   55s] test test_overwrite_middle_of_file ... ok
[   55s] test test_seek_buffer ... ok
[   55s] test test_seek_file ... ok
[   55s] test test_seek_read_buffer ... ok
[   55s] test test_seek_read_file ... ok
[   55s] test test_set_len_file ... ok
[   55s] test test_set_len_rollover ... ok
[   55s] test test_set_len_buffer ... ok
[   55s] test test_sparse_write_rollover ... ok
[   55s] test test_sparse_buffer ... ok
[   55s] test test_sparse_file ... ok
[   55s]
[   55s] test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s
[   55s]
[   55s] + for unit_test in '${unit_test_list}'
[   55s] + ./tempdir
[   55s]
[   55s] running 2 tests
[   55s] test test_customnamed ... ok
[   55s] test main ... ok
[   55s]
[   55s] test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s
[   55s]
[   55s] + for unit_test in '${unit_test_list}'
[   55s] + ./tempfile
[   55s]
[   55s] running 3 tests
[   55s] test test_basic ... ok
[   55s] test test_cleanup ... ok
[   55s] test test_pathological_cleaner ... ok
[   55s]
[   55s] test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.14s

packaging/rust-tempfile.spec

index 60c7e75943bdd1e614d0fe7276d2f6665efd5527..c49af41afa4138654c7984b227132b6cc7530a8e 100644 (file)
@@ -50,20 +50,44 @@ cp %{SOURCE1} .
 # crate-type : dylib, proc-macro, cdylib, bin, etc.
 # ==========================================================
 %build
- %{rustc_std_build} --crate-type=dylib \
-         --crate-name=%{real_crate_name} \
-         %{?rustc_edition:--edition=%{rustc_edition}} \
-         %rust_dylib_extern cfg_if \
-         %rust_dylib_extern rustix \
-         %rust_dylib_extern fastrand \
-         ./src/lib.rs
+%{rustc_std_build} --crate-type=dylib \
+        --crate-name=%{real_crate_name} \
+        %{?rustc_edition:--edition=%{rustc_edition}} \
+        %rust_dylib_extern cfg_if \
+        %rust_dylib_extern rustix \
+        %rust_dylib_extern fastrand \
+        ./src/lib.rs
 
 # ==========================================================
 # install section
 # ==========================================================
 %install
- install -d -m 0755 %{buildroot}%{_rust_dylibdir}
- install -m 0644 lib%{real_crate_name}.so %{buildroot}/%{_rust_dylibdir}/lib%{real_crate_name}.so
+install -d -m 0755 %{buildroot}%{_rust_dylibdir}
+install -m 0644 lib%{real_crate_name}.so %{buildroot}/%{_rust_dylibdir}/lib%{real_crate_name}.so
+
+%check
+%if 0%{?run_tests}
+
+export unit_test_list="namedtempfile spooled tempdir tempfile"
+
+for unit_test in ${unit_test_list}
+do
+%{rustc_std_build} --test --crate-type=dylib \
+        --crate-name=${unit_test} \
+        %{?rustc_edition:--edition=%{rustc_edition}} \
+        --extern %{real_crate_name}=./lib%{real_crate_name}.so \
+        %rust_dylib_extern cfg_if \
+        %rust_dylib_extern rustix \
+        %rust_dylib_extern fastrand \
+        ./tests/${unit_test}.rs
+done
+
+for unit_test in ${unit_test_list}
+do
+./${unit_test}
+done
+
+%endif
 
 %clean
 
@@ -76,6 +100,6 @@ cp %{SOURCE1} .
 # ==========================================================
 %files
 %manifest %{name}.manifest
- %license LICENSE-APACHE
- %license LICENSE-MIT
- %{_rust_dylibdir}/lib%{real_crate_name}.so
+%license LICENSE-APACHE
+%license LICENSE-MIT
+%{_rust_dylibdir}/lib%{real_crate_name}.so