Add unittest
authorRoy7Kim <myoungwoon.kim@samsung.com>
Fri, 26 May 2023 05:51:37 +0000 (14:51 +0900)
committerRoy7Kim <myoungwoon.kim@samsung.com>
Fri, 26 May 2023 05:51:47 +0000 (14:51 +0900)
[   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

packaging/rust-linux-raw-sys.spec

index c3621f058f1182103e9c0b61ef84cb441dbbc2da..24be04aa4982249973cfca4e7617dd43938fd462 100644 (file)
@@ -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