forked from agama-project/agama
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37b9cf9
commit 2fa44fb
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' | ||
RESULT=0 | ||
MIGRATE_WICKED_BIN=../../target/debug/migrate-wicked | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd $SCRIPT_DIR | ||
TEST_DIRS=$(ls -d */ | sed 's#/##') | ||
|
||
error_msg() { | ||
echo -e "${RED}Error for test $1: $2${NC}" | ||
} | ||
|
||
if [[ $(ls -A /etc/NetworkManager/system-connections/) ]]; then | ||
echo -e "${RED}There are already NM connections. You may be running this script on a live system, which is highly discouraged!${NC}" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f $MIGRATE_WICKED_BIN ]; then | ||
echo -e "${RED}No migrate-wicked binary found${NC}" | ||
exit 1 | ||
fi | ||
|
||
for test_dir in ${TEST_DIRS}; do | ||
echo "Testing ${test_dir}" | ||
$MIGRATE_WICKED_BIN show $test_dir/wicked_xml | ||
if [ $? -ne 0 ]; then | ||
error_msg ${test_dir} "show failed" | ||
RESULT=1 | ||
fi | ||
$MIGRATE_WICKED_BIN migrate $test_dir/wicked_xml | ||
if [ $? -ne 0 ]; then | ||
error_msg ${test_dir} "migration failed" | ||
RESULT=1 | ||
continue | ||
fi | ||
for cmp_file in $(ls $test_dir/system-connections/); do | ||
diff --unified=0 --color=always -I uuid $test_dir/system-connections/$cmp_file /etc/NetworkManager/system-connections/${cmp_file/\./\*.} | ||
if [ $? -ne 0 ]; then | ||
error_msg ${test_dir} "$cmp_file didn't match" | ||
RESULT=1 | ||
else | ||
echo -e "${GREEN}Migration for connection ${cmp_file/\.*/} successful${NC}" | ||
fi | ||
done | ||
rm -f /etc/NetworkManager/system-connections/* | ||
done | ||
|
||
if [ $RESULT -eq 0 ]; then | ||
echo -e "${GREEN}All tests successful${NC}" | ||
else | ||
echo -e "${RED}Some tests failed${NC}" | ||
fi | ||
exit $RESULT |