ssh [email protected]
Ref:
https://uworbital.notion.site/How-to-GDB-67f9c81be6974e929e80dcffca9d04ba
scp /Users/genichihashi/Desktop/tests/* [email protected]:~/cs246/1239/a2
<aside> 💡 Testing
Testing a Program Manually and With Simple Automation
Example 2: Automating the Tests With bash Scripts
</aside>
<aside> 💡 Debugging
how to use valgrind
 to debug memory issues in a program.
This video demonstrates using gdb
 to debug a real (buggy!) program:
</aside>
<aside> 💡 Submission
**[update_q3.sh]**
#!/bin/bash
./produceOutputs suiteq3.txt ./voting
zip a1q3.zip suiteq3.txt *.in *.out *.args
marmoset_submit cs246 a1q3 a1q3.zip
run with args
../execs/a1q3-provided $(cat sample1.args) < sample1.in
chmod u+x ./update_q3.sh
</aside>
<aside> 💡 Download file to Desktop
</aside>
<aside> 💡 How we compile? - must be in dependency order
g++20m -c vec.cc
g++20m -c vec-impl.cc
g++20m -c main.cc
g++20m vec.o vec-impl.o main.o -o main
./main
Dependency order - interface must be compiled before implementation, client
Build tool spprt for compiling in dependency order (e.g. make) is still a work in progress
</aside>
<aside> 💡 Short Cuts (run chmod +x name.sh)
./getOutput.sh a2q2
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $0 <executable>"
exit 1
fi
executable="$1"
if [ ! -x "$executable" ]; then
echo "Error: '$executable' is not an executable file."
exit 1
fi
for input_file in *.in; do
if [ -e "$input_file" ]; then
output_file="${input_file%.in}.out"
./"$executable" < "$input_file" > "$output_file"
echo "Processed: $input_file -> $output_file"
fi
done
echo "Done!"
./collect.sh **.** suite.txt
#!/bin/bash
# Check for the correct number of arguments
if [ $# -ne 2 ]; then
echo "Usage: $0 <directory> <output_file>"
exit 1
fi
# Assign the directory and output file to variables
directory="$1"
output_file="$2"
# Check if the directory exists
if [ ! -d "$directory" ]; then
echo "Error: Directory '$directory' does not exist."
exit 1
fi
# Find files ending with ".in" in the specified directory,
# extract their base names (without path and ".in" extension), and write them to the output file
find "$directory" -type f -name "*.in" -exec basename {} .in \\; > "$output_file"
echo "File names ending with '.in' in $directory have been written to $output_file."
</aside>