Skip to content

Commit

Permalink
Added ability to run speech e2e tests on Windows (cygwin)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlivan-microsoft authored and unknown committed Aug 12, 2015
1 parent 1807711 commit ca189d8
Show file tree
Hide file tree
Showing 6 changed files with 1,524 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run-test text eol=lf
3 changes: 2 additions & 1 deletion MachineLearning/CNTK/CNTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,8 @@ int wmain(int argc, wchar_t* argv[])
fcloseOrDie(fp);
}
fprintf(stderr, "COMPLETED\n");
}
fflush(stderr);
}
catch (const std::exception &err)
{
fprintf(stderr, "EXCEPTION occurred: %s\n", err.what());
Expand Down
738 changes: 738 additions & 0 deletions Tests/Speech/QuickE2E/baseline.windows.cpu.txt

Large diffs are not rendered by default.

738 changes: 738 additions & 0 deletions Tests/Speech/QuickE2E/baseline.windows.gpu.txt

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions Tests/Speech/QuickE2E/run-test
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
#!/bin/bash
CNTK_BINARY=$TEST_BUILD_LOCATION/$TEST_FLAVOR/bin/cntk
if [ "$TEST_DEVICE" == "CPU" ]; then
CNTK_DEVICE_ID=-1
else
CNTK_DEVICE_ID=Auto
fi
CNTK_ARGS="configFile=$TEST_DIR/cntk.config RunDir=$TEST_RUN_DIR DataDir=$TEST_DATA_DIR DeviceId=$CNTK_DEVICE_ID"

configFile=$TEST_DIR/cntk.config
RunDir=$TEST_RUN_DIR
DataDir=$TEST_DATA_DIR

if [ "$OS" == "Windows_NT" ]; then
# When running on cygwin translating /cygdrive/xxx paths to proper windows paths:
configFile=$(cygpath -aw $configFile)
RunDir=$(cygpath -aw $RunDir)
DataDir=$(cygpath -aw $DataDir)
fi

CNTK_ARGS="configFile=$configFile RunDir=$RunDir DataDir=$DataDir DeviceId=$CNTK_DEVICE_ID"
MODELS_DIR=$TEST_RUN_DIR/models
[ -d $MODELS_DIR ] && rm -rf $MODELS_DIR
mkdir -p $MODELS_DIR || exit $?
echo === Running $CNTK_BINARY $CNTK_ARGS
$CNTK_BINARY $CNTK_ARGS || exit $?
echo === Running $TEST_CNTK_BINARY $CNTK_ARGS
$TEST_CNTK_BINARY $CNTK_ARGS || exit $?
echo === Deleting last epoch data
rm $TEST_RUN_DIR/models/*.dnn
echo ==== Re-running from checkpoint
$CNTK_BINARY $CNTK_ARGS || exit $?
$TEST_CNTK_BINARY $CNTK_ARGS || exit $?
44 changes: 29 additions & 15 deletions Tests/TestDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
# Each test directory has a following components:
# - testcases.yml - main test confuguration file, whcih defines all test cases
# - run-test - (run-test) script
# - run-test - (run-test) script
# - baseline*.txt - baseline files whith a captured expected output of run-test script
#
# ----- testcases.yml format -------
Expand Down Expand Up @@ -52,10 +52,14 @@
# ---- Baseline files ----
# Order of searching baseline files, depends on the current mode for a given test:
#
# 1. baseline.<flavor>.<device>.txt
# 2. baseline.<flavor>.txt
# 3. baseline.<device>.txt
# 4. baseline.txt
# 1. baseline.<os>.<flavor>.<device>.txt
# 2. baseline.<os>.<flavor>.txt
# 3. baseline.<os>.<device>.txt
# 4. baseline.<os>.txt
# 5. baseline.<flavor>.<device>.txt
# 6. baseline.<flavor>.txt
# 7. baseline.<device>.txt
# 8. baseline.txt
# where <flavor> = { debug | release }
# <device> = { cpu | gpu }
#
Expand All @@ -79,6 +83,7 @@
import sys, os, argparse, traceback, yaml, subprocess, random, re, time

thisDir = os.path.dirname(os.path.realpath(__file__))
windows = os.getenv("OS")=="Windows_NT"

# This class encapsulates an instance of the test
class Test:
Expand Down Expand Up @@ -169,6 +174,10 @@ def run(self, flavor, device, args):
os.environ["TEST_FLAVOR"] = flavor
os.environ["TEST_DEVICE"] = device
os.environ["TEST_BUILD_LOCATION"] = args.build_location
if windows:
os.environ["TEST_CNTK_BINARY"] = os.path.join(args.build_location, flavor, "cntk.exe")
else:
os.environ["TEST_CNTK_BINARY"] = os.path.join(args.build_location, flavor, "bin", "cntk")
os.environ["TEST_DIR"] = self.testDir
os.environ["TEST_DATA_DIR"] = self.dataDir
os.environ["TEST_RUN_DIR"] = runDir
Expand Down Expand Up @@ -237,17 +246,22 @@ def run(self, flavor, device, args):
return result

# Finds a location of a baseline file by probing different names in the following order:
# baseline.$os.$flavor.$device.txt
# baseline.$os.$flavor.txt
# baseline.$os.$device.txt
# baseline.$os.txt
# baseline.$flavor.$device.txt
# baseline.$flavor.txt
# baseline.$device.txt
# baseline.txt
def findBaselineFile(self, flavor, device):
for f in ["." + flavor.lower(), ""]:
for d in ["." + device.lower(), ""]:
candidateName = "baseline" + f + d + ".txt";
fullPath = os.path.join(self.testDir, candidateName)
if os.path.isfile(fullPath):
return fullPath
for o in ["." + ("windows" if windows else "linux"), ""]:
for f in ["." + flavor.lower(), ""]:
for d in ["." + device.lower(), ""]:
candidateName = "baseline" + o + f + d + ".txt"
fullPath = os.path.join(self.testDir, candidateName)
if os.path.isfile(fullPath):
return fullPath
return None

# This class encapsulates one testcase (in testcases.yml file)
Expand Down Expand Up @@ -521,13 +535,13 @@ def runCommand(args):
help="optional test name(s) to run, specified as Suite/TestName. "
"Use list command to list available tests. "
"If not specified then all tests will be run.")
#TODO: port paths to Windows
defaultBuildLocation=os.path.realpath(os.path.join(thisDir, "..", "build"))
defaultBuildLocation=os.path.realpath(os.path.join(thisDir, "..", "x64" if windows else "build"))

runSubparser.add_argument("-b", "--build-location", default=defaultBuildLocation, help="location of the CNTK build to run")
runSubparser.add_argument("-d", "--device", help="cpu|gpu - run on a specific device")
runSubparser.add_argument("-f", "--flavor", help="release|debug - run only a specific flavor")
#TODO: port paths to Windows
defaultRunDir=os.path.join("/tmp", "cntk-test-{0}.{1}".format(time.strftime("%Y%m%d%H%M%S"), random.randint(0,1000000)))
tmpDir = os.getenv("TEMP") if windows else "/tmp"
defaultRunDir=os.path.join(tmpDir, "cntk-test-{0}.{1}".format(time.strftime("%Y%m%d%H%M%S"), random.randint(0,1000000)))
runSubparser.add_argument("-r", "--run-dir", default=defaultRunDir, help="directory where to store test output, default: a random dir within /tmp")
runSubparser.add_argument("--update-baseline", action='store_true', help="update baseline file(s) instead of matching them")
runSubparser.add_argument("-v", "--verbose", action='store_true', help="verbose output - dump all output of test script")
Expand Down

0 comments on commit ca189d8

Please sign in to comment.