Skip to content

michael1017/LFX_Mentorship_2023

Repository files navigation

LFX Mentorship 2023

Description

LFX Mentorship 2023 01-Mar-May Challenge - WasmEdge

Getting Started

Dependency

For Basic Install:

  • Clang
  • GNU Make
  • WasmEdge Library

For Testing:
Need to fulfill the basic install requirement, then install the following tools:

  • Clang++
  • llvm
  • Google Test

Installation

Docker Install

The project builds the latest master branch image and publish it on docker hub. The image contains compiled project binary called x.

Pull the image from docker hub:

docker pull mike1017/lfx_mentorship_2023:latest

Execute the binary in container.

docker run --rm -it mike1017/lfx_mentorship_2023 ./x version
docker run --rm -it mike1017/lfx_mentorship_2023 ./x wasm_app/wasm/add.wasm 1 2
docker run --rm -it mike1017/lfx_mentorship_2023 ./x version wasm_app/wasm/add.wasm 1 2

Source Install

The project uses GNU Make system to build the source. Several things can be configured before starting to build. To learn more detail about configuration, please check customize Makefile

For Basic Install: By default, it will generate a execution file called x. To change the default execution name, please check customize Makefile

make all

Clean up object files and executions produced by make all and make test

make clean

Execution

./x [version] [run] [wasm path] [arguments]
`./x` is the default execution name.  
`version` print WasmEdge version
`run` is optional; expect the following arguments are `wasm path` and `arguments`.  
`wasm path` is required; the relative or absolute path of wasm app.  
`arguments` is optional; support i32, i64, f32 and f64 input.

Example:

./x wasm_app/wasm/add.wasm 2 3 
./x run wasm_app/wasm/add.wasm 3 2 
./x version wasm_app/wasm/add.wasm 00100 -0
./x version run wasm_app/wasm/add.wasm +005 - 

Testing

Run Google Test

By default, it will generate a execution file called x_testall. To change the default execution name, please check customize Makefile. The testing may print some error messages, this is because the test includes illegal test cases to check its error handling ability. Developers only need to check if "PASSED" is printed at the end of the tests.

make test
./x_testall

The "PASSED" message should be like this:

Clean up object files and executions produced by make test

make clean_test

Run Clang Source-Based Code Coverage

sh coverage_test.sh

The report should be like this:

Implementation Report

This section shows how I implemented the tool and provides screenshots of execution results.

Reference