From 5df9de7085c156553cc578a0a76d0e3a7d28cdca Mon Sep 17 00:00:00 2001 From: keengo99 <3189199@qq.com> Date: Thu, 5 Dec 2024 15:34:23 +0800 Subject: [PATCH] add workflows test --- .github/workflows/kangle.yml | 7 ++++++- test/test_framework/common/assert.go | 3 ++- test/test_framework/framework/main.go | 15 +++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/kangle.yml b/.github/workflows/kangle.yml index fe28ce1..9c2a371 100644 --- a/.github/workflows/kangle.yml +++ b/.github/workflows/kangle.yml @@ -14,10 +14,15 @@ jobs: steps: - uses: actions/checkout@v4 - name: prepare - run: sudo apt -y install g++ liburing-dev libjemalloc-dev libz-dev libpcre3-dev libbrotli-dev libssl-dev cmake libsqlite3-dev + run: sudo apt -y install g++ golang liburing-dev libjemalloc-dev libz-dev libpcre3-dev libbrotli-dev libssl-dev cmake libsqlite3-dev - name: submodule run: git submodule init && git submodule update - name: cmake run: mkdir build && cd build && cmake .. -DLINUX_IOURING=ON -DENABLE_BROTLI=1 - name: make run: cd build && make + - name: build test + run: cd test && ./build.sh + - name: test + run: cd test && ./test.sh + diff --git a/test/test_framework/common/assert.go b/test/test_framework/common/assert.go index b038fa3..b948b06 100644 --- a/test/test_framework/common/assert.go +++ b/test/test_framework/common/assert.go @@ -55,11 +55,12 @@ func Assert(test_name string, expression bool) bool { success_count++ return true } -func Report() { +func Report() (sc int, fc int) { fmt.Printf("success_count=[%d],failed_count=[%d]\n", success_count, failed_count) if failed_count == 0 { fmt.Printf("***************test passed**********\n") } else { fmt.Printf("@@@@@@@@@@@@@@@test failed@@@@@@@@@@\n") } + return success_count, failed_count } diff --git a/test/test_framework/framework/main.go b/test/test_framework/framework/main.go index a1c80e9..59041e6 100644 --- a/test/test_framework/framework/main.go +++ b/test/test_framework/framework/main.go @@ -33,7 +33,7 @@ var ( prepare_config *bool = flag.Bool("p", false, "only prepare config") ) -func ProcessSuites(suites []string) { +func ProcessSuites(suites []string) (success_count int, failed_count int) { defer func() { if err := recover(); err != nil { fmt.Println(err) //这里的err其实就是panic传入的内容,55 @@ -62,7 +62,7 @@ func ProcessSuites(suites []string) { } } if *prepare_config { - return + return 0, 0 } if *server_model { server.Start() @@ -93,11 +93,12 @@ func ProcessSuites(suites []string) { } } } - common.Report() + success_count, fc := common.Report() if len(*kangle_exe) > 0 { suite.Clean(suites) kangle.Close() } + return success_count, fc } func handle_signal() { c := make(chan os.Signal, 1) @@ -147,7 +148,9 @@ func Main() { suites = strings.Split(*test_case, ",") } go handle_signal() - ProcessSuites(suites) - b := make([]byte, 1) - os.Stdin.Read(b) + _, fc := ProcessSuites(suites) + if fc > 0 { + os.Exit(1) + } + os.Exit(0) }