Skip to content

Commit

Permalink
test: Add WASI unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Feb 1, 2021
1 parent 837d83a commit a084bf5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
include(GoogleTest)

add_executable(fizzy-unittests)
target_link_libraries(fizzy-unittests PRIVATE fizzy::fizzy-internal fizzy::test-utils GTest::gtest_main GTest::gmock)
target_link_libraries(fizzy-unittests PRIVATE fizzy::fizzy-internal fizzy::wasi fizzy::test-utils GTest::gtest_main GTest::gmock)

target_sources(
fizzy-unittests PRIVATE
Expand Down Expand Up @@ -40,6 +40,7 @@ target_sources(
validation_stack_type_test.cpp
validation_test.cpp
value_test.cpp
wasi_test.cpp
wasm_engine_test.cpp
)

Expand Down
20 changes: 20 additions & 0 deletions test/unittests/wasi_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Fizzy: A fast WebAssembly interpreter
// Copyright 2020 The Fizzy Authors.
// SPDX-License-Identifier: Apache-2.0

#include "wasi.hpp"
#include <gtest/gtest.h>
#include <test/utils/hex.hpp>
#include <sstream>

using namespace fizzy;
using namespace fizzy::test;

TEST(wasi, no_file)
{
const char* args[]{"ABC"};

std::ostringstream err;
EXPECT_FALSE(wasi::run(std::size(args), args, err));
EXPECT_EQ(err.str(), "File does not exists or is irregular: ABC\n");
}

0 comments on commit a084bf5

Please sign in to comment.