Run the cgpt tests in a separate directory.

I'm getting ready to add a bunch more cgpt tests. This is just to clear the
way.

Change-Id: I5cb781e85938b94da9c59528872ddfd386712726

Review URL: http://codereview.chromium.org/3162023
diff --git a/tests/common.sh b/tests/common.sh
index 1e2ca03..cd7695f 100755
--- a/tests/common.sh
+++ b/tests/common.sh
@@ -5,15 +5,7 @@
 # found in the LICENSE file.
 
 # Determine script directory.
-if [[ $0 == '/'* ]];
-then
-  SCRIPT_DIR="`dirname $0`"
-elif [[ $0 == './'* ]];
-then
-  SCRIPT_DIR="`pwd`"
-else
-  SCRIPT_DIR="`pwd`"/"`dirname $0`"
-fi
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
 
 ROOT_DIR="$(dirname ${SCRIPT_DIR})"
 BUILD_DIR="${ROOT_DIR}/build"
diff --git a/tests/run_cgpt_tests.sh b/tests/run_cgpt_tests.sh
index b70af2f..9171a86 100755
--- a/tests/run_cgpt_tests.sh
+++ b/tests/run_cgpt_tests.sh
@@ -9,16 +9,19 @@
 # Load common constants and variables.
 . "$(dirname "$0")/common.sh"
 
-GPT=$1
+GPT=$(readlink -f "$1")
 [ -x "$GPT" ] || error "Can't execute $GPT"
-warning "testing $GPT"
+
+# Run tests in a dedicated directory for easy cleanup or debugging.
+DIR="${TEST_DIR}/cgpt_test_dir"
+[ -d "$DIR" ] || mkdir -p "$DIR"
+warning "testing $GPT in $DIR"
+cd "$DIR"
 
 echo "Create an empty file to use as the device..."
 NUM_SECTORS=1000
-DEV=$(mktemp)
-BOOTFILE=$(mktemp)
+DEV=fake_dev.bin
 dd if=/dev/zero of=${DEV} conv=notrunc bs=512 count=${NUM_SECTORS} 2>/dev/null
-trap "rm -f ${DEV}" EXIT
 
 
 echo "Create a bunch of partitions, using the real GUID types..."