Skip to content

Commit

Permalink
refactor: move all tests to tests dir
Browse files Browse the repository at this point in the history
  • Loading branch information
vfusco committed Jan 23, 2024
1 parent 2b7c19a commit a511059
Show file tree
Hide file tree
Showing 108 changed files with 74,463 additions and 804 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
**/*.dtb
**/*.bin
**/*.md

**/Dockerfile*
**/*.deb

build
third-party/downloads
Expand Down
138 changes: 66 additions & 72 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "lib/grpc-interfaces"]
path = lib/grpc-interfaces
url = ../grpc-interfaces.git
[submodule "tests/riscv-tests"]
path = tests/riscv-tests
url = ../riscv-tests.git
[submodule "tests/riscv-arch-test"]
path = tests/riscv-arch-test
url = ../riscv-arch-test.git
34 changes: 11 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ ARG SANITIZE=no

RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
build-essential vim wget git clang-tidy-15 clang-format-15 lcov \
libboost1.81-dev libssl-dev \
ca-certificates pkg-config lua5.4 liblua5.4-dev \
libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc \
luarocks xxd && \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 120 && \
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 120 && \
build-essential vim wget git clang-tidy-15 clang-format-15 lcov \
libboost1.81-dev libssl-dev \
ca-certificates pkg-config lua5.4 liblua5.4-dev \
libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc \
luarocks xxd && \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 120 && \
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 120 && \
rm -rf /var/lib/apt/lists/*


Expand All @@ -37,34 +37,22 @@ COPY third-party third-party
RUN make -j$(nproc) dep

FROM --platform=$TARGETPLATFORM dep-builder as builder
ARG DEB_FILENAME=cartesi-machine.deb

COPY . .
RUN make -j$(nproc) git_commit=$GIT_COMMIT release=$RELEASE coverage=$COVERAGE sanitize=$SANITIZE


FROM --platform=$TARGETPLATFORM builder as debian-packager
RUN make install-uarch debian-package DESTDIR=$PWD/_install

FROM --platform=$TARGETPLATFORM debian-packager as installer
ARG MACHINE_EMULATOR_VERSION=0.0.0
ARG TARGETARCH

RUN make install-tests
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y \
./cartesi-machine-v${MACHINE_EMULATOR_VERSION}_${TARGETARCH}.deb \
&& rm -rf /var/lib/apt/lists/*

ENV CARTESI_TESTS_PATH="/usr/share/cartesi-machine/tests"
ENV CARTESI_IMAGES_PATH="/usr/share/cartesi-machine/images"
RUN make install-uarch debian-package DESTDIR=$PWD/_install

FROM --platform=$TARGETPLATFORM debian:bookworm-20230725-slim
ARG MACHINE_EMULATOR_VERSION=0.0.0
ARG TARGETARCH

COPY --from=installer \
/usr/src/emulator/cartesi-machine-v${MACHINE_EMULATOR_VERSION}_${TARGETARCH}.deb \
cartesi-machine.deb
COPY --from=debian-packager \
/usr/src/emulator/cartesi-machine-v${MACHINE_EMULATOR_VERSION}_${TARGETARCH}.deb \
cartesi-machine.deb
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y \
./cartesi-machine.deb \
&& rm -rf /var/lib/apt/lists/* \
Expand Down
192 changes: 122 additions & 70 deletions Makefile

Large diffs are not rendered by default.

47 changes: 30 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@ The emulator implements RISC-V's RV64IMASU ISA. The letters after RV specify the
Run `make help` for a list of target options. Here are some of them:

```
Main targets:
* all - build the src/ code. To build from a clean clone, run: make submodules downloads dep all
uarch - build microarchitecture (requires riscv64-cartesi-linux-gnu-* toolchain)
uarch-with-linux-env - build microarchitecture using the linux-env docker image
build-tests - Build machine emulator tests (requires rv64gc-lp64d riscv64-cartesi-linux-gnu-* toolchain)
build-tests-with-toolchain - Build machine emulator tests using the rv64gc-lp64d toolchain docker image
build-tests-uarch - build microarchitecture rv64i instruction tests (requires rv64ima-lp64 riscv64-cartesi-linux-gnu-* toolchain)
build-tests-uarch-with-toolchain - build microarchitecture rv64i instruction tests using the rv64ima-lp64 toolchain docker image
test-machine - Run machine emulator tests
test-uarch - Run uarch tests
test - Build and run all tests
doc - build the doxygen documentation (requires doxygen)
Docker images targets:
build-debian-image - Build the machine-emulator debian based docker image
build-debian-package - Build the cartesi-machine.deb package from image
build-linux-env - Build the linux environment docker image
Cleaning targets:
clean - clean the src/ artifacts
depclean - clean + dependencies
distclean - depclean + profile information and downloads
Docker targets:
build-debian-image - Build the machine-emulator debian based docker image
clean - clean the src/ artifacts
depclean - clean + dependencies
distclean - depclean + profile information and downloads
```

### Requirements
Expand Down Expand Up @@ -46,7 +60,7 @@ sudo luarocks install --lua-version=5.4 luaposix

##### MacPorts
```bash
sudo port install clang-15 boost libtool wget pkgconfig grpc openssl lua lua-luarocks
sudo port install clang-15 boost181 wget pkgconfig grpc lua54 lua-luarocks

sudo luarocks install --lua-version=5.4 lpeg
sudo luarocks install --lua-version=5.4 dkjson
Expand All @@ -70,16 +84,13 @@ For emulator scripts to work it is expected that `lua5.4` binary is available in
### Build

```bash
make submodules
make downloads
make dep
git clone --recurse-submodules -j3 https://github.com/cartesi/machine-emulator.git
make
```

Cleaning:

```bash
make depclean
make clean
```

Expand All @@ -102,8 +113,6 @@ sudo make install PREFIX=/usr/local
Both `libcartesi` and `libcartes_jsonrpc` C libraries can be compiled in standalone, either as static or shared library:

```bash
make submodules
make downloads
make dep
make bundle-boost
make -C src release=yes libcartesi.a libcartesi_jsonrpc.a libcartesi.so libcartesi_jsonrpc.so
Expand Down Expand Up @@ -134,16 +143,22 @@ make -C src release=yes \

## Running Tests

Copy the tests binaries to a directory called `tests` and run: (Eg.: )
To build and execute the all tests run:

```bash
make test
```

The default search path for binaries is `machine-emulator/tests`. Alternatively you can specify the binaries path using the `CARTESI_TESTS_PATH` variable as in:
To execute the machine test suite run:

```bash
make test-machine
```

To execute the uarch test suite run:

```bash
make test CARTESI_TESTS_PATH=/full/path/to/test/binaries
make test-uarch
```

## Linter
Expand Down Expand Up @@ -231,13 +246,11 @@ make coverage-toolchain=clang -j$(nproc)
### Running coverage

After building the emulator with coverage enable, you should run the following command.
You need to specify the binaries test path using the `CARTESI_TESTS_PATH` variable.
You also need to specify the directory containing the kernel and rootfs with the `CARTESI_IMAGES_PATH` variable.
For instance:

```bash
make coverage=yes test-all coverage-report \
CARTESI_TESTS_PATH=$(realpath ../tests/build) \
CARTESI_IMAGES_PATH=$(realpath ./src)
```

Expand Down
Loading

0 comments on commit a511059

Please sign in to comment.