-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
207 lines (184 loc) · 6.12 KB
/
test.sh
File metadata and controls
207 lines (184 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
# Test script for Rocket Welder SDK
# Tests all three language implementations against a GStreamer pipeline
set -e
# Default configuration
BUFFER_NAME="test_buffer"
FRAME_COUNT=20
MODE="duplex" # Default mode
# Parse command line arguments
for arg in "$@"; do
case $arg in
--exit-after=*)
FRAME_COUNT="${arg#*=}"
shift
;;
--mode=*)
MODE="${arg#*=}"
if [[ "$MODE" != "duplex" && "$MODE" != "oneway" ]]; then
echo "Error: Mode must be 'duplex' or 'oneway'"
exit 1
fi
shift
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --exit-after=N Exit after N frames (default: 20)"
echo " --mode=MODE Connection mode: duplex or oneway (default: duplex)"
echo " --help Show this help message"
exit 0
;;
*)
echo "Unknown argument: $arg"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Build connection string with mode parameter
CONNECTION_STRING="shm://${BUFFER_NAME}?mode=${MODE}"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "========================================="
echo "Rocket Welder SDK Test Suite"
echo "========================================="
echo ""
echo "Configuration:"
echo " Buffer: ${BUFFER_NAME}"
echo " Frames: ${FRAME_COUNT}"
echo " Mode: ${MODE}"
echo " Connection: ${CONNECTION_STRING}"
echo ""
# Check if gst-launch-1.0 is available
if ! command -v gst-launch-1.0 &> /dev/null; then
echo -e "${RED}✗ Error: gst-launch-1.0 not found${NC}"
echo "Please install GStreamer first"
exit 1
fi
# Check if zerosink plugin is available
# First try with the built plugin path
export GST_PLUGIN_PATH=/mnt/d/source/modelingevolution/streamer/src/gstreamer/zerobuffer/build:$GST_PLUGIN_PATH
if ! gst-inspect-1.0 zerosink &> /dev/null; then
echo -e "${YELLOW}⚠ Warning: zerosink plugin not found${NC}"
echo "Tests will use fakesink instead (mock mode)"
USE_MOCK=1
else
echo -e "${GREEN}✓ Found zerosink plugin${NC}"
fi
# Function to run test for a specific language
run_test() {
local LANG=$1
local RUN_SCRIPT=$2
echo -e "\n${YELLOW}Testing ${LANG}...${NC}"
# Start GStreamer pipeline in background
if [ -z "$USE_MOCK" ]; then
echo "Starting GStreamer pipeline with zerosink..."
gst-launch-1.0 videotestsrc num-buffers=${FRAME_COUNT} pattern=ball ! \
video/x-raw,width=640,height=480,framerate=30/1,format=RGB ! \
zerosink buffer-name=${BUFFER_NAME} sync=false &> gst_${LANG}.log &
else
echo "Starting mock GStreamer pipeline..."
gst-launch-1.0 videotestsrc num-buffers=${FRAME_COUNT} ! \
video/x-raw,width=640,height=480,framerate=30/1 ! \
fakesink sync=false &> gst_${LANG}.log &
fi
GST_PID=$!
# Give pipeline time to initialize
sleep 2
# Run the client
echo "Running ${LANG} client..."
if timeout 10 ${RUN_SCRIPT} "${CONNECTION_STRING}" --exit-after=${FRAME_COUNT} > output_${LANG}.log 2>&1; then
CLIENT_EXIT_CODE=0
else
CLIENT_EXIT_CODE=$?
fi
# Stop GStreamer pipeline
kill $GST_PID 2>/dev/null || true
wait $GST_PID 2>/dev/null || true
# Check results
if [ $CLIENT_EXIT_CODE -eq 0 ]; then
# Check if client processed expected number of frames
if grep -q "Total frames processed: ${FRAME_COUNT}" output_${LANG}.log; then
echo -e "${GREEN}✓ ${LANG} test passed${NC}"
echo " - Client connected successfully"
echo " - Processed ${FRAME_COUNT} frames"
echo " - Exited cleanly"
return 0
elif grep -q "Processed frame" output_${LANG}.log; then
PROCESSED=$(grep -c "Processed frame" output_${LANG}.log || echo "0")
echo -e "${YELLOW}⚠ ${LANG} test partial${NC}"
echo " - Client processed ${PROCESSED}/${FRAME_COUNT} frames"
if [ -n "$USE_MOCK" ]; then
echo " - Running in mock mode (zerosink not available)"
return 0 # Don't fail in mock mode
fi
return 1
else
echo -e "${RED}✗ ${LANG} test failed${NC}"
echo " - No frames processed"
echo " - Check output_${LANG}.log for details"
return 1
fi
else
echo -e "${RED}✗ ${LANG} test failed${NC}"
echo " - Client exited with code: $CLIENT_EXIT_CODE"
if [ $CLIENT_EXIT_CODE -eq 124 ]; then
echo " - Client timed out"
fi
echo " - Check output_${LANG}.log for details"
return 1
fi
}
# Track test results
TESTS_PASSED=0
TESTS_FAILED=0
# Test C++
if [ -f "${SCRIPT_DIR}/cpp/run.sh" ]; then
if run_test "C++" "${SCRIPT_DIR}/cpp/run.sh"; then
((TESTS_PASSED++))
else
((TESTS_FAILED++))
fi
else
echo -e "${YELLOW}⚠ Skipping C++ (run.sh not found)${NC}"
fi
# Test C#
if [ -f "${SCRIPT_DIR}/csharp/run.sh" ]; then
if run_test "C#" "${SCRIPT_DIR}/csharp/run.sh"; then
((TESTS_PASSED++))
else
((TESTS_FAILED++))
fi
else
echo -e "${YELLOW}⚠ Skipping C# (run.sh not found)${NC}"
fi
# Test Python
if [ -f "${SCRIPT_DIR}/python/run.sh" ]; then
if run_test "Python" "${SCRIPT_DIR}/python/run.sh"; then
((TESTS_PASSED++))
else
((TESTS_FAILED++))
fi
else
echo -e "${YELLOW}⚠ Skipping Python (run.sh not found)${NC}"
fi
# Summary
echo ""
echo "========================================="
echo "Test Summary"
echo "========================================="
echo -e "${GREEN}Passed: ${TESTS_PASSED}${NC}"
echo -e "${RED}Failed: ${TESTS_FAILED}${NC}"
if [ $TESTS_FAILED -eq 0 ]; then
echo -e "\n${GREEN}All tests passed!${NC}"
exit 0
else
echo -e "\n${RED}Some tests failed. Check output_*.log files for details.${NC}"
exit 1
fi