Remove hardcoded home path from test scripts
Share directories are now created under \$DATA_ROOT/<peer>/share/ with generated dummy files instead of pointing at /home/frejoh/Downloads. Tests are now fully self-contained and safe to share. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,15 @@ DATA_ROOT="/tmp/waste-test"
|
|||||||
rm -rf "$DATA_ROOT"
|
rm -rf "$DATA_ROOT"
|
||||||
mkdir -p "$DATA_ROOT/bin"
|
mkdir -p "$DATA_ROOT/bin"
|
||||||
|
|
||||||
|
# Seed per-peer share directories with dummy files.
|
||||||
|
mkdir -p "$DATA_ROOT/alice/share" "$DATA_ROOT/bob/share" "$DATA_ROOT/charlie/share"
|
||||||
|
echo "alice's notes" > "$DATA_ROOT/alice/share/notes.txt"
|
||||||
|
dd if=/dev/urandom bs=1K count=64 2>/dev/null | base64 > "$DATA_ROOT/alice/share/photo.jpg.b64"
|
||||||
|
dd if=/dev/urandom bs=1K count=128 2>/dev/null | base64 > "$DATA_ROOT/bob/share/archive.tar.b64"
|
||||||
|
echo -e "file1.mp3\nfile2.mp3" > "$DATA_ROOT/bob/share/playlist.m3u"
|
||||||
|
echo "charlie's doc" > "$DATA_ROOT/charlie/share/document.txt"
|
||||||
|
echo "#!/bin/sh" > "$DATA_ROOT/charlie/share/script.sh"
|
||||||
|
|
||||||
# Kill any leftover processes from a previous run holding our fixed ports.
|
# Kill any leftover processes from a previous run holding our fixed ports.
|
||||||
for port in "$ANCHOR_PORT" "$ALICE_IPC" "$BOB_IPC" "$CHARLIE_IPC"; do
|
for port in "$ANCHOR_PORT" "$ALICE_IPC" "$BOB_IPC" "$CHARLIE_IPC"; do
|
||||||
pid=$(lsof -ti tcp:"$port" 2>/dev/null || true)
|
pid=$(lsof -ti tcp:"$port" 2>/dev/null || true)
|
||||||
@@ -206,7 +215,7 @@ log "$ALICE_COLOR" "alice" "starting daemon (ipc :${ALICE_IPC})"
|
|||||||
-data-dir "$DATA_ROOT/alice" \
|
-data-dir "$DATA_ROOT/alice" \
|
||||||
-ipc-port "$ALICE_IPC" \
|
-ipc-port "$ALICE_IPC" \
|
||||||
-anchor "$ANCHOR_URL" \
|
-anchor "$ANCHOR_URL" \
|
||||||
-share-dir "/home/frejoh/Downloads/alice" \
|
-share-dir "$DATA_ROOT/alice/share" \
|
||||||
2> >(while IFS= read -r l; do echo -e "${ALICE_COLOR}${DIM}[alice] ${l}${RESET}"; done) &
|
2> >(while IFS= read -r l; do echo -e "${ALICE_COLOR}${DIM}[alice] ${l}${RESET}"; done) &
|
||||||
PIDS+=($!)
|
PIDS+=($!)
|
||||||
|
|
||||||
@@ -216,7 +225,7 @@ log "$BOB_COLOR" "bob" "starting daemon (ipc :${BOB_IPC})"
|
|||||||
-data-dir "$DATA_ROOT/bob" \
|
-data-dir "$DATA_ROOT/bob" \
|
||||||
-ipc-port "$BOB_IPC" \
|
-ipc-port "$BOB_IPC" \
|
||||||
-anchor "$ANCHOR_URL" \
|
-anchor "$ANCHOR_URL" \
|
||||||
-share-dir "/home/frejoh/Downloads/bob" \
|
-share-dir "$DATA_ROOT/bob/share" \
|
||||||
2> >(while IFS= read -r l; do echo -e "${BOB_COLOR}${DIM}[bob] ${l}${RESET}"; done) &
|
2> >(while IFS= read -r l; do echo -e "${BOB_COLOR}${DIM}[bob] ${l}${RESET}"; done) &
|
||||||
PIDS+=($!)
|
PIDS+=($!)
|
||||||
|
|
||||||
@@ -226,7 +235,7 @@ log "$CHARLIE_COLOR" "charlie" "starting daemon (ipc :${CHARLIE_IPC})"
|
|||||||
-data-dir "$DATA_ROOT/charlie" \
|
-data-dir "$DATA_ROOT/charlie" \
|
||||||
-ipc-port "$CHARLIE_IPC" \
|
-ipc-port "$CHARLIE_IPC" \
|
||||||
-anchor "$ANCHOR_URL" \
|
-anchor "$ANCHOR_URL" \
|
||||||
-share-dir "/home/frejoh/Downloads/charlie" \
|
-share-dir "$DATA_ROOT/charlie/share" \
|
||||||
2> >(while IFS= read -r l; do echo -e "${CHARLIE_COLOR}${DIM}[charlie]${l}${RESET}"; done) &
|
2> >(while IFS= read -r l; do echo -e "${CHARLIE_COLOR}${DIM}[charlie]${l}${RESET}"; done) &
|
||||||
PIDS+=($!)
|
PIDS+=($!)
|
||||||
|
|
||||||
|
|||||||
15
test-tui.sh
15
test-tui.sh
@@ -19,6 +19,15 @@ CYAN='\033[0;36m'; DIM='\033[2m'; BOLD='\033[1m'; RESET='\033[0m'
|
|||||||
rm -rf "$DATA_ROOT"
|
rm -rf "$DATA_ROOT"
|
||||||
mkdir -p "$DATA_ROOT/bin"
|
mkdir -p "$DATA_ROOT/bin"
|
||||||
|
|
||||||
|
# Seed per-peer share directories with dummy files.
|
||||||
|
mkdir -p "$DATA_ROOT/alice/share" "$DATA_ROOT/bob/share" "$DATA_ROOT/charlie/share"
|
||||||
|
echo "alice's notes" > "$DATA_ROOT/alice/share/notes.txt"
|
||||||
|
dd if=/dev/urandom bs=1K count=64 2>/dev/null | base64 > "$DATA_ROOT/alice/share/photo.jpg.b64"
|
||||||
|
dd if=/dev/urandom bs=1K count=128 2>/dev/null | base64 > "$DATA_ROOT/bob/share/archive.tar.b64"
|
||||||
|
echo -e "file1.mp3\nfile2.mp3" > "$DATA_ROOT/bob/share/playlist.m3u"
|
||||||
|
echo "charlie's doc" > "$DATA_ROOT/charlie/share/document.txt"
|
||||||
|
echo "#!/bin/sh" > "$DATA_ROOT/charlie/share/script.sh"
|
||||||
|
|
||||||
# Kill any leftover processes holding our fixed ports.
|
# Kill any leftover processes holding our fixed ports.
|
||||||
for port in "$ANCHOR_PORT" "$ALICE_IPC" "$BOB_IPC" "$CHARLIE_IPC"; do
|
for port in "$ANCHOR_PORT" "$ALICE_IPC" "$BOB_IPC" "$CHARLIE_IPC"; do
|
||||||
pid=$(lsof -ti tcp:"$port" 2>/dev/null || true)
|
pid=$(lsof -ti tcp:"$port" 2>/dev/null || true)
|
||||||
@@ -91,17 +100,17 @@ ANCHOR_URL="ws://127.0.0.1:${ANCHOR_PORT}/ws"
|
|||||||
# Daemons
|
# Daemons
|
||||||
"$DATA_ROOT/bin/waste-daemon" -alias alice -data-dir "$DATA_ROOT/alice" \
|
"$DATA_ROOT/bin/waste-daemon" -alias alice -data-dir "$DATA_ROOT/alice" \
|
||||||
-ipc-port "$ALICE_IPC" -anchor "$ANCHOR_URL" \
|
-ipc-port "$ALICE_IPC" -anchor "$ANCHOR_URL" \
|
||||||
-share-dir "/home/frejoh/Downloads/alice" 2>/dev/null &
|
-share-dir "$DATA_ROOT/alice/share" 2>/dev/null &
|
||||||
PIDS+=($!)
|
PIDS+=($!)
|
||||||
|
|
||||||
"$DATA_ROOT/bin/waste-daemon" -alias bob -data-dir "$DATA_ROOT/bob" \
|
"$DATA_ROOT/bin/waste-daemon" -alias bob -data-dir "$DATA_ROOT/bob" \
|
||||||
-ipc-port "$BOB_IPC" -anchor "$ANCHOR_URL" \
|
-ipc-port "$BOB_IPC" -anchor "$ANCHOR_URL" \
|
||||||
-share-dir "/home/frejoh/Downloads/bob" 2>/dev/null &
|
-share-dir "$DATA_ROOT/bob/share" 2>/dev/null &
|
||||||
PIDS+=($!)
|
PIDS+=($!)
|
||||||
|
|
||||||
"$DATA_ROOT/bin/waste-daemon" -alias charlie -data-dir "$DATA_ROOT/charlie" \
|
"$DATA_ROOT/bin/waste-daemon" -alias charlie -data-dir "$DATA_ROOT/charlie" \
|
||||||
-ipc-port "$CHARLIE_IPC" -anchor "$ANCHOR_URL" \
|
-ipc-port "$CHARLIE_IPC" -anchor "$ANCHOR_URL" \
|
||||||
-share-dir "/home/frejoh/Downloads/charlie" 2>/dev/null &
|
-share-dir "$DATA_ROOT/charlie/share" 2>/dev/null &
|
||||||
PIDS+=($!)
|
PIDS+=($!)
|
||||||
|
|
||||||
wait_port "$ALICE_IPC"
|
wait_port "$ALICE_IPC"
|
||||||
|
|||||||
Reference in New Issue
Block a user