adding all files this time
This commit is contained in:
parent
06f09b28c1
commit
5f7b4b5696
25 changed files with 3176 additions and 0 deletions
93
tests/run_tests.sh
Normal file
93
tests/run_tests.sh
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Basic test script for apt-layer C implementation
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test counter
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
|
||||
# Test function
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local command="$2"
|
||||
local expected_exit="$3"
|
||||
|
||||
echo -e "${YELLOW}Running test: $test_name${NC}"
|
||||
echo "Command: $command"
|
||||
|
||||
# Run the command
|
||||
if eval "$command" > /dev/null 2>&1; then
|
||||
exit_code=0
|
||||
else
|
||||
exit_code=$?
|
||||
fi
|
||||
|
||||
# Check result
|
||||
if [ "$exit_code" -eq "$expected_exit" ]; then
|
||||
echo -e "${GREEN}✓ Test passed: $test_name${NC}"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
echo -e "${RED}✗ Test failed: $test_name (expected $expected_exit, got $exit_code)${NC}"
|
||||
((TESTS_FAILED++))
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
# Check if binary exists
|
||||
if [ ! -f "../bin/apt-layer" ]; then
|
||||
echo -e "${RED}Error: apt-layer binary not found. Please build the project first.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting apt-layer C implementation tests..."
|
||||
echo "=========================================="
|
||||
echo
|
||||
|
||||
# Test 1: Help command
|
||||
run_test "Help command" "../bin/apt-layer --help" 0
|
||||
|
||||
# Test 2: Version command
|
||||
run_test "Version command" "../bin/apt-layer --version" 0
|
||||
|
||||
# Test 3: Invalid arguments
|
||||
run_test "Invalid arguments" "../bin/apt-layer --invalid-option" 1
|
||||
|
||||
# Test 4: Missing arguments for layer creation
|
||||
run_test "Missing arguments for layer creation" "../bin/apt-layer" 1
|
||||
|
||||
# Test 5: Missing arguments for container
|
||||
run_test "Missing arguments for container" "../bin/apt-layer --container" 1
|
||||
|
||||
# Test 6: Missing arguments for oci-export
|
||||
run_test "Missing arguments for oci-export" "../bin/apt-layer --oci-export" 1
|
||||
|
||||
# Test 7: List command (should fail without OSTree repo)
|
||||
run_test "List command without repo" "../bin/apt-layer --list" 2
|
||||
|
||||
# Test 8: Info command without branch
|
||||
run_test "Info command without branch" "../bin/apt-layer --info" 1
|
||||
|
||||
# Test 9: Rollback command without branch
|
||||
run_test "Rollback command without branch" "../bin/apt-layer --rollback" 1
|
||||
|
||||
echo "=========================================="
|
||||
echo "Test Results:"
|
||||
echo -e "${GREEN}Passed: $TESTS_PASSED${NC}"
|
||||
echo -e "${RED}Failed: $TESTS_FAILED${NC}"
|
||||
echo "Total: $((TESTS_PASSED + TESTS_FAILED))"
|
||||
|
||||
if [ $TESTS_FAILED -eq 0 ]; then
|
||||
echo -e "${GREEN}All tests passed!${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo -e "${RED}Some tests failed!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue