Skip to content

Commit 6115b71

Browse files
committed
ignore warnings
Signed-off-by: joejiong <1004691415qq@gmail.com> ignore warnings Signed-off-by: joejiong <1004691415qq@gmail.com> ignore warnings Signed-off-by: joejiong <1004691415qq@gmail.com> separate test and build Signed-off-by: joejiong <1004691415qq@gmail.com> modify rights Signed-off-by: joejiong <1004691415qq@gmail.com> Add cmakelist export-bmv2 test target Signed-off-by: joejiong <1004691415qq@gmail.com> Folder structure Signed-off-by: joejiong <1004691415qq@gmail.com> align test Signed-off-by: joejiong <1004691415qq@gmail.com> thread 1 Signed-off-by: joejiong <1004691415qq@gmail.com> clean cache Signed-off-by: joejiong <1004691415qq@gmail.com> more Signed-off-by: joejiong <1004691415qq@gmail.com> more Signed-off-by: joejiong <1004691415qq@gmail.com> more Signed-off-by: joejiong <1004691415qq@gmail.com> modify lit config Signed-off-by: joejiong <1004691415qq@gmail.com> fine tests Signed-off-by: joejiong <1004691415qq@gmail.com> recover cache Signed-off-by: joejiong <1004691415qq@gmail.com> git action cache changed script path, so I change the base address to workspace address Signed-off-by: joejiong <1004691415qq@gmail.com> clean Signed-off-by: joejiong <1004691415qq@gmail.com> new test Signed-off-by: joejiong <1004691415qq@gmail.com> clean Signed-off-by: joejiong <1004691415qq@gmail.com> disable gc, cause in future it is still need to merge to translate, somehow preserve the flow Signed-off-by: joejiong <1004691415qq@gmail.com>
1 parent 929c3d7 commit 6115b71

File tree

10 files changed

+95
-18
lines changed

10 files changed

+95
-18
lines changed

.github/workflows/build-and-test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ jobs:
6161
# --------
6262

6363
- name: Build and test MLIR
64-
if: steps.cache-llvm.outputs.cache-hit != 'true'
6564
run: |
66-
build_tools/build_mlir.sh
65+
build_tools/build_mlir.sh 2>&1 | tee build_mlir.log
66+
cat build_mlir.log
6767
6868
# --------
6969
# Build and test P4MLIR.
@@ -72,3 +72,8 @@ jobs:
7272
- name: Build and test P4MLIR
7373
run: |
7474
build_tools/build_p4c_with_p4mlir_ext.sh
75+
76+
- name: Run P4MLIR tests
77+
run: |
78+
build_tools/unittest.sh 2>&1 | tee unittest.log
79+
cat unittest.log

build_tools/build_p4c_with_p4mlir_ext.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,4 @@ cd "$P4C_BUILD_DIR"
5959
cmake -G Ninja "$P4C_REPO_DIR" $CMAKE_FLAGS
6060
ninja
6161

62-
# Run some tests
63-
ninja check-p4mlir
6462

65-
# Install
66-
ninja install

build_tools/unittest.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
echo "SCRIPT_DIR: $SCRIPT_DIR"
6+
7+
SCRIPT_DIR="${GITHUB_WORKSPACE}/build_tools"
8+
9+
echo "SCRIPT_DIR: $SCRIPT_DIR"
10+
11+
P4MLIR_REPO_DIR=$( cd "$SCRIPT_DIR"/.. &> /dev/null && pwd )
12+
13+
P4C_REPO_DIR=$P4MLIR_REPO_DIR/third_party/p4c
14+
P4C_BUILD_DIR=$P4C_REPO_DIR/build
15+
P4C_EXT_DIR=$P4C_REPO_DIR/extensions
16+
P4C_P4MLIR_EXT_DIR=$P4C_EXT_DIR/p4mlir
17+
LLVM_LIT="$P4MLIR_REPO_DIR/third_party/llvm-project/build/bin/llvm-lit"
18+
TEST_DIR="$P4MLIR_REPO_DIR/third_party/p4c/build/extensions/p4mlir/test"
19+
20+
cd "$P4C_BUILD_DIR"
21+
echo "*********** Listing all available tests ***************"
22+
TEST_LIST=$($LLVM_LIT --show-tests "$TEST_DIR")
23+
24+
TOTAL_TESTS=0
25+
PASSED_TESTS=0
26+
FAILED_TESTS=0
27+
28+
TESTS=()
29+
while IFS= read -r line; do
30+
TESTS+=("$line")
31+
done < <($LLVM_LIT --show-tests "$TEST_DIR" | grep "P4MLIR ::" | sed 's/^ P4MLIR :: //')
32+
33+
for TEST_ITEM in "${TESTS[@]}"; do
34+
35+
FULL_TEST_PATH="$TEST_DIR/$TEST_ITEM"
36+
37+
echo "Test Item: $TEST_ITEM"
38+
echo "Full Test Path: $FULL_TEST_PATH"
39+
40+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
41+
42+
if $LLVM_LIT -v "$FULL_TEST_PATH"; then
43+
PASSED_TESTS=$((PASSED_TESTS + 1))
44+
echo "PASSED"
45+
else
46+
FAILED_TESTS=$((FAILED_TESTS + 1))
47+
echo "FAILED"
48+
fi
49+
done
50+
51+
52+
echo "==== Test Summary ===="
53+
echo "Total tests: $TOTAL_TESTS"
54+
echo "Passed tests: $PASSED_TESTS"
55+
echo "Failed tests: $FAILED_TESTS"
56+
57+
echo "==== Installing ===="
58+
ninja install

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(P4MLIR_TEST_DEPENDS
99
FileCheck count not
1010
p4mlir-opt
1111
p4mlir-translate
12+
p4mlir-export-bmv2
1213
)
1314

1415
add_lit_testsuite(check-p4mlir "Running the P4MLIR regression tests"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ module {
44
%1 = p4hir.const #p4hir.bool<false> : !p4hir.bool
55
}
66

7-
// CHECK: p4hir.const
7+
// CHECK: p4hir.const

test/lit.cfg.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
# -*- Python -*-
2-
31
import os
42
import platform
5-
import re
6-
import subprocess
7-
import tempfile
8-
93
import lit.formats
104
import lit.util
11-
125
from lit.llvm import llvm_config
136
from lit.llvm.subst import ToolSubst
147
from lit.llvm.subst import FindTool
@@ -18,7 +11,9 @@
1811
# name: The name of this test suite.
1912
config.name = "P4MLIR"
2013

21-
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
14+
# Check if use_lit_shell exists, fallback to True if not
15+
use_lit_shell = getattr(llvm_config, "use_lit_shell", True)
16+
config.test_format = lit.formats.ShTest(not use_lit_shell)
2217

2318
# suffixes: A list of file extensions to treat as test files.
2419
config.suffixes = [".mlir", ".p4"]
@@ -56,7 +51,7 @@
5651
"mlir-opt",
5752
"p4mlir-opt",
5853
"p4mlir-translate",
59-
"p4mlir-export-bmv2",
54+
"p4mlir-export-bmv2"
6055
]
6156

6257
llvm_config.add_tool_substitutions(tools, tool_dirs)

tools/p4mlir-export-bmv2/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mlir_check_all_link_libraries(p4mlir-export-bmv2)
2929

3030
add_custom_target(linkp4mlir_export_out
3131
COMMAND ${CMAKE_COMMAND} -E create_symlink
32-
${P4MLIR_BINARY_DIR}/bin/p4mlir-export-bmv2
32+
${P4MLIR_BINARY_DIR}/bin/p4mlir-export-bmv2
3333
${P4C_BINARY_DIR}/p4mlir-export-bmv2
3434
COMMAND ${CMAKE_COMMAND} -E create_symlink
3535
${P4C_BINARY_DIR}/p4include

tools/p4mlir-export-bmv2/json_emitter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ See the License for the specific language governing permissions and
1010
limitations under the License.
1111
*/
1212

13-
#include "json_emitter.h"
13+
#pragma GCC diagnostic push
14+
#pragma GCC diagnostic ignored "-Wunused-parameter"
1415
#include "p4mlir/Dialect/P4HIR/P4HIR_Dialect.h"
1516
#include "llvm/Support/JSON.h"
1617
#include "llvm/Support/raw_ostream.h"
18+
#pragma GCC diagnostic pop
19+
20+
21+
#include "json_emitter.h"
22+
1723

1824
using namespace llvm::json;
1925

tools/p4mlir-export-bmv2/json_emitter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ limitations under the License.
1313
#ifndef P4MLIR_JSON_EMITTER_H
1414
#define P4MLIR_JSON_EMITTER_H
1515

16+
#pragma GCC diagnostic push
17+
#pragma GCC diagnostic ignored "-Wunused-parameter"
1618
#include "mlir/IR/BuiltinOps.h"
1719
#include "mlir/IR/Operation.h"
1820
#include "llvm/Support/JSON.h"
21+
#pragma GCC diagnostic pop
22+
1923

2024
namespace P4::P4MLIR {
2125

tools/p4mlir-export-bmv2/p4mlir-export-bmv2.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ limitations under the License.
1616
#include <iostream>
1717
#include "options.h"
1818

19+
#if HAVE_LIBGC
20+
extern "C" {
21+
#include "gc.h"
22+
}
23+
#endif
24+
1925
#pragma GCC diagnostic push
2026
#pragma GCC diagnostic ignored "-Wunused-parameter"
2127
#include "mlir/IR/OperationSupport.h"
@@ -27,8 +33,14 @@ limitations under the License.
2733
#include "json_emitter.h"
2834

2935

36+
37+
3038
int main(int argc, char *const argv[]) {
3139

40+
#if HAVE_LIBGC
41+
GC_disable();
42+
#endif
43+
3244
P4::AutoCompileContext autoP4MLIRExportContext(new P4::MLIR::ExportContext);
3345
auto &options = P4::MLIR::ExportContext::get().options();
3446
options.langVersion = P4::CompilerOptions::FrontendVersion::P4_16;

0 commit comments

Comments
 (0)