summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TESTING53
-rwxr-xr-xvm.sh39
2 files changed, 73 insertions, 19 deletions
diff --git a/TESTING b/TESTING
index ecbc5d0..998224a 100644
--- a/TESTING
+++ b/TESTING
@@ -1,5 +1,7 @@
Testing KPL With QEMU
+---
+
Requirements:
qemu-system-x86-64
@@ -7,35 +9,60 @@ qemu-system-aarch64
ed2k
wget
ssh
+rsync
+
+---
+
+Note X64 = X86-64 and A64 = Aarch64
Setup:
-Run
-./vm.sh -init
-Run
-./vm.sh -cli X64 # Set up root password for X86-64 machine
+./vm.sh -init # Create the enviroment
+./vm.sh -cli X64 # Set up root password for X64 machine
./vm.sh -setup # Follow instructions
-./vm.sh -cli A64 # Set up root password for Aarch64 machine
+./vm.sh -cli A64 # Set up root password for A64 machine
./vm.sh -setup # Follow instructions
+---
+
Starting:
-Run
./vm.sh -start # Start both X64 and A64 machines
+./vm.sh -start X64 # Start X64
+./vm.sh -start A64 # Start A64
+
+---
+
+Syncing:
+
+./vm.sh -sync # Sync the codebase on both X64 and A64 machines
+./vm.sh -sync X64 # Sync on X64
+./vm.sh -sync A64 # Sync on A64
+
+---
+
+Testing:
+
+./vm.sh -test # Sync and test the codebase on both X64 and A64 machines
+./vm.sh -test X64 # Sync and test the codebase on X64
+./vm.sh -test A64 # Sync and test the codebase on A64
+---
+
+Accessing:
./vm.sh -ssh X64 # SSH into X86-64
./vm.sh -ssh A64 # SSH into Aarch64
-Testing:
+---
Stopping:
-To poweroff both machines run
-./vm.sh -stop
-To force stop QEMU use
-./vm.sh -kill
+./vm.sh -stop # Power off A64 and X64 machines
+./vm.sh -kill # Force stop QEMU
+
+---
Cleaning:
-To remove the testing environment run
-./vm.sh -clean
+./vm.sh -clean # Remove the testing environment
+
diff --git a/vm.sh b/vm.sh
index 3a44733..516aeb7 100755
--- a/vm.sh
+++ b/vm.sh
@@ -5,6 +5,7 @@ OPTION="$1"
VM="$2"
DIR="qemu"
USER="user"
+HOST="localhost"
CORES="4"
MEMORY="4G"
DEVICE="virtio-net-pci,netdev=net0"
@@ -105,20 +106,27 @@ vm_boot() {
CMD+=("$ARG")
done
"${CMD[@]}"
+ echo "Starting VM $1"
}
vm_cli() {
+ cd $DIR
vm_check $VM
if [[ $? != 0 ]]
then
return
fi
- cd $DIR
vm_boot $VM "-nographic"
}
vm_start() {
cd $DIR
+ vm_check $VM
+ if [[ $? == 0 ]]
+ then
+ vm_boot $VM "-display" "none" "-daemonize"
+ return
+ fi
for NAME in "${NAMES[@]}"
do
vm_boot $NAME "-display" "none" "-daemonize"
@@ -131,18 +139,30 @@ vm_cmd() {
then
return
fi
- ssh-add "$USER/$USER"
- ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$USER@localhost" -p "${SSH_PORTS[$1]}" $2
+ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$USER@$HOST" -p "${SSH_PORTS[$1]}" $2
}
vm_ssh() {
cd $DIR
+ ssh-add "$USER/$USER" &> /dev/null
vm_cmd $VM
}
+vm_sync() {
+ echo "TODO ${FUNCNAME[0]}"
+}
+
+vm_test() {
+ echo "TODO ${FUNCNAME[0]}"
+}
+
vm_stop() {
- local ACTION=$1
+ local ACTION="$1"
cd $DIR
+ if [[ "$ACTION" != "KILL" ]]
+ then
+ ssh-add "$USER/$USER" &> /dev/null
+ fi
for NAME in "${NAMES[@]}"
do
local PID_FILE="${PID_FILES[$NAME]}"
@@ -151,8 +171,10 @@ vm_stop() {
if [[ "$ACTION" == "KILL" ]]
then
kill $(cat $PID_FILE)
+ echo "VM $NAME force stop"
else
vm_cmd $NAME "sudo poweroff"
+ echo "VM $NAME powering off"
fi
fi
done
@@ -171,11 +193,12 @@ vm_clean() {
return
fi
rm -r $DIR
- echo -e "\nRemoved $DIR testing directory"
+ echo -e "\nRemoved $DIR directory"
}
vm_help() {
- echo "Usage $SCRIPT -init|-cli|-start|-ssh|-test|-stop|-kill|-clean|-help"
+ echo "See TESTING"
+ echo "Usage $SCRIPT -init|-setup|-cli|-start|-ssh|-sync|-test|-stop|-kill|-clean|-help"
}
case $OPTION in
@@ -194,7 +217,11 @@ case $OPTION in
-ssh)
vm_ssh
;;
+ -sync)
+ vm_sync
+ ;;
-test)
+ vm_test
;;
-stop)
vm_stop