From: Roy7Kim Date: Fri, 26 May 2023 05:51:37 +0000 (+0900) Subject: Add unittest X-Git-Tag: accepted/tizen/rust/20231016.021431^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e3d76f10f58fb9d40e03402350f6a6ea1ae5b4a;p=platform%2Fupstream%2Frust-linux-raw-sys.git Add unittest [ 18s] + ./linux_raw_sys [ 18s] [ 18s] running 0 tests [ 18s] [ 18s] test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s --- diff --git a/packaging/rust-linux-raw-sys.spec b/packaging/rust-linux-raw-sys.spec index c3621f0..24be04a 100644 --- a/packaging/rust-linux-raw-sys.spec +++ b/packaging/rust-linux-raw-sys.spec @@ -26,8 +26,10 @@ BuildRequires: rust # ========================================================== # dev-dependencies # ========================================================== -# BuildRequires: rust-libc -# BuildRequires: rust-static_assertions +%if 0%{?run_tests} +BuildRequires: rust-libc +BuildRequires: rust-static_assertions +%endif %description @@ -63,22 +65,61 @@ export RUSTC_TARGET_POINTER_WIDTH=64 export RUSTC_TARGET_ARCH=arm export RUSTC_TARGET_POINTER_WIDTH=32 %endif - %{rustc_std_build} --crate-type=dylib \ - --crate-name=%{real_crate_name} \ - %{?rustc_edition:--edition=%{rustc_edition}} \ - --cfg="target_arch=\"$RUSTC_TARGET_ARCH\"" \ - --cfg="target_pointer_width=\"$RUSTC_TARGET_POINTER_WIDTH\"" \ - --cfg='feature="std"' \ - --cfg='feature="general"' \ - --cfg='feature="errno"' \ - ./src/lib.rs +%{rustc_std_build} --crate-type=dylib \ + --crate-name=%{real_crate_name} \ + %{?rustc_edition:--edition=%{rustc_edition}} \ + --cfg="target_arch=\"$RUSTC_TARGET_ARCH\"" \ + --cfg="target_pointer_width=\"$RUSTC_TARGET_POINTER_WIDTH\"" \ + --cfg='feature="std"' \ + --cfg='feature="general"' \ + --cfg='feature="errno"' \ + ./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} + +%ifarch %{ix86} +export RUSTC_TARGET_ARCH=x86 +export RUSTC_TARGET_POINTER_WIDTH=32 +%endif +%ifarch x86_64 +export RUSTC_TARGET_ARCH=x86_64 +export RUSTC_TARGET_POINTER_WIDTH=64 +%endif +%ifarch armv7l +export RUSTC_TARGET_ARCH=arm +export RUSTC_TARGET_POINTER_WIDTH=32 +%endif +%ifarch aarch64 +export RUSTC_TARGET_ARCH=aarch64 +export RUSTC_TARGET_POINTER_WIDTH=64 +%endif +%ifarch armv7hl +export RUSTC_TARGET_ARCH=arm +export RUSTC_TARGET_POINTER_WIDTH=32 +%endif + +%{rustc_std_build} --test --crate-type=dylib \ + --crate-name=%{real_crate_name} \ + %{?rustc_edition:--edition=%{rustc_edition}} \ + --cfg="target_arch=\"$RUSTC_TARGET_ARCH\"" \ + --cfg="target_pointer_width=\"$RUSTC_TARGET_POINTER_WIDTH\"" \ + --cfg='feature="std"' \ + --cfg='feature="general"' \ + --cfg='feature="errno"' \ + %rust_dylib_extern static_assertions \ + %rust_dylib_extern libc \ + ./src/lib.rs + +./%{real_crate_name} +%endif %clean @@ -91,7 +132,7 @@ export RUSTC_TARGET_POINTER_WIDTH=32 # ========================================================== %files %manifest %{name}.manifest - %license LICENSE-APACHE - %license LICENSE-MIT - %license LICENSE-Apache-2.0_WITH_LLVM-exception - %{_rust_dylibdir}/lib%{real_crate_name}.so +%license LICENSE-APACHE +%license LICENSE-MIT +%license LICENSE-Apache-2.0_WITH_LLVM-exception +%{_rust_dylibdir}/lib%{real_crate_name}.so