test_policy.sh raw
1 #!/bin/bash
2
3 # Policy System Test Runner
4 # This script runs all policy-related tests and benchmarks
5
6 set -e
7
8 # Pure Go build with purego - no CGO needed
9 # libsecp256k1 is loaded dynamically at runtime if available
10 export CGO_ENABLED=0
11 if [ -f "$(dirname "$0")/../pkg/crypto/p8k/libsecp256k1.so" ]; then
12 export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$(dirname "$0")/../pkg/crypto/p8k"
13 fi
14
15 echo "๐งช Running Policy System Tests"
16 echo "================================"
17
18 # Change to the project directory
19 cd "$(dirname "$0")"
20
21 # Run policy package tests
22 echo ""
23 echo "๐ฆ Running Policy Package Tests..."
24 go test -v ./pkg/policy/... -run "Test.*" -timeout 30s
25
26 # Run policy integration tests
27 echo ""
28 echo "๐ Running Policy Integration Tests..."
29 go test -v ./app/... -run "TestPolicy.*" -timeout 30s
30
31 # Run policy benchmarks
32 echo ""
33 echo "โก Running Policy Benchmarks..."
34 go test -v ./pkg/policy/... -run "Benchmark.*" -bench=. -benchmem -timeout 60s
35
36 # Run edge case tests
37 echo ""
38 echo "๐ Running Edge Case Tests..."
39 go test -v ./pkg/policy/... -run "TestEdge.*" -timeout 30s
40
41 # Run race condition tests
42 echo ""
43 echo "๐ Running Race Condition Tests..."
44 go test -v ./pkg/policy/... -race -timeout 30s
45
46 # Run coverage analysis
47 echo ""
48 echo "๐ Running Coverage Analysis..."
49 go test -v ./pkg/policy/... -coverprofile=coverage.out
50 go tool cover -html=coverage.out -o coverage.html
51 echo "Coverage report generated: coverage.html"
52
53 # Check for any linting issues
54 echo ""
55 echo "๐ Running Linter Checks..."
56 golangci-lint run ./pkg/policy/... || echo "Linter not available, skipping..."
57
58 echo ""
59 echo "โ
All Policy Tests Completed!"
60 echo "================================"
61