Skip to content
Snippets Groups Projects
Commit d9aa1395 authored by Millian Poquet's avatar Millian Poquet
Browse files

unit tests++

parent da0a4ed0
Branches
No related tags found
No related merge requests found
Pipeline #4503 passed
...@@ -11,7 +11,10 @@ debian: ...@@ -11,7 +11,10 @@ debian:
script: script:
# Get various dependencies # Get various dependencies
- apt update -y - apt update -y
- apt install -y g++ libsimgrid-dev libzmq3-dev libprotobuf-dev protobuf-compiler libgtest-dev meson ninja-build pkg-config python3 python3-pip - apt install -y g++ libsimgrid-dev libzmq3-dev libprotobuf-dev protobuf-compiler libgtest-dev meson ninja-build pkg-config python3 python3-pip python3-pytest
# Put pip-installed binaries in PATH
- export PATH="${PATH}:/usr/local/bin"
# Build protocol (c++) # Build protocol (c++)
- (cd protocol && meson setup build --prefix=/usr && ninja -C build && meson install -C build) - (cd protocol && meson setup build --prefix=/usr && ninja -C build && meson install -C build)
...@@ -29,10 +32,13 @@ debian: ...@@ -29,10 +32,13 @@ debian:
# Run unit tests (simgrid simulator, c++) # Run unit tests (simgrid simulator, c++)
- (cd simgrid-simulator && meson test -C build) - (cd simgrid-simulator && meson test -C build)
# Run unit tests (python)
- (cd client-py && pytest .)
# Run integration tests (simgrid simulator VS c++ client) # Run integration tests (simgrid simulator VS c++ client)
- test/simulator-cpp-client.sh - test/simulator-cpp-client.sh
# Run integration tests (simgrid simulator VS python client) # Run integration tests (simgrid simulator VS python client)
- PATH="${PATH}:/usr/local/bin" test/simulator-py-client.sh - test/simulator-py-client.sh
artifacts: artifacts:
paths: paths:
- client-cpp.err - client-cpp.err
...@@ -54,5 +60,6 @@ nix: ...@@ -54,5 +60,6 @@ nix:
# Any dependency will also be built, for example the following command also builds protocol-python # Any dependency will also be built, for example the following command also builds protocol-python
- nix-build . -A client-py - nix-build . -A client-py
# Therefore one can just run its desired leaf of the build tree, such as: # Therefore one can just run its desired leaf of the build tree, such as:
- nix-shell . -A client-py_unittest_shell --command '(cd client-py && pytest)'
- nix-shell . -A integration_shell_cpp --command './test/simulator-cpp-client.sh' - nix-shell . -A integration_shell_cpp --command './test/simulator-cpp-client.sh'
- nix-shell . -A integration_shell_py --command './test/simulator-py-client.sh' - nix-shell . -A integration_shell_py --command './test/simulator-py-client.sh'
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
import zmq import zmq
import protocol.hello_pb2 as proto import protocol.hello_pb2 as proto
def some_function(x):
return x*2
def main(): def main():
context = zmq.Context() context = zmq.Context()
socket = context.socket(zmq.REP) socket = context.socket(zmq.REP)
......
#!/usr/bin/env python3
import client
def test_some_function():
for i in range(10):
assert(client.some_function(i) == i*2)
...@@ -44,7 +44,11 @@ let self = rec { ...@@ -44,7 +44,11 @@ let self = rec {
"src" "src"
"src/.*\.cpp" "src/.*\.cpp"
"src/.*\.hpp" "src/.*\.hpp"
"test"
"test/.*\.cpp"
]; ];
mesonFlags = [ "-Ddo_unit_tests=true" ];
doCheck = true;
buildInputs = with pkgs; [ buildInputs = with pkgs; [
simgrid simgrid
protocol-cpp protocol-cpp
...@@ -85,6 +89,11 @@ let self = rec { ...@@ -85,6 +89,11 @@ let self = rec {
]; ];
}; };
client-py_unittest_shell = pkgs.mkShell {
buildInputs = client-py.propagatedBuildInputs ++ [
pythonPackages.pytest
];
};
integration_shell_cpp = pkgs.mkShell { integration_shell_cpp = pkgs.mkShell {
buildInputs = [ buildInputs = [
simgrid-simulator simgrid-simulator
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment