def test_WriteClientLibraryFromSolutions(tmpdir): Common.globalParameters["MergeFiles"] = True Common.globalParameters["CodeObjectVersion"] = "V3" Common.globalParameters["YAML"] = True Common.globalParameters["CxxCompiler"] = "hipcc" Common.assignGlobalParameters({}) libraryWorkingPath = tmpdir.mkdir("lib") buildWorkingPath = tmpdir.mkdir("build") scriptDir = os.path.dirname(os.path.realpath(__file__)) dataDir = os.path.realpath( os.path.join(scriptDir, "..", "test_data", "unit")) solutionsFilePath = os.path.join(dataDir, "solutions", "solutions_nn_3.yaml") fileSolutions = LibraryIO.parseSolutionsFile(solutionsFilePath) solutions = fileSolutions[1] Common.setWorkingPath(buildWorkingPath) TensileCreateLibrary.WriteClientLibraryFromSolutions( solutions, libraryWorkingPath) Common.popWorkingPath() tensileLibraryPath = os.path.join(libraryWorkingPath, "library") hsacoFiles = glob.glob(tensileLibraryPath + "/*hsaco") assert (len(hsacoFiles) > 0) coFiles = glob.glob(tensileLibraryPath + "/*TensileLibrary*co") assert (len(coFiles) > 0) tensileYamlFilePath = os.path.join(tensileLibraryPath, "TensileLibrary.yaml") assert os.path.exists(tensileYamlFilePath) == 1 config = None try: stream = open(tensileYamlFilePath, "r") except IOError: mylogger.error("Cannot open file: %s" % tensileYamlFilePath) config = yaml.load(stream, yaml.SafeLoader) stream.close() actualSolutions = config["solutions"] assert (len(actualSolutions) == 3) metadataYamlFilePath = os.path.join(tensileLibraryPath, "metadata.yaml") assert os.path.exists(metadataYamlFilePath) == 1 metadata = None try: stream = open(metadataYamlFilePath, "r") except IOError: mylogger.error("Cannot open file: %s" % metadataYamlFilePath) metadata = yaml.load(stream, yaml.SafeLoader) stream.close() actualProblemType = metadata["ProblemType"] assert (len(actualProblemType) > 0)
def test_paths(): workingPathName = "working/path" Common.globalParameters["WorkingPath"] = workingPathName expectedWorkingPath = "working/path" assert Common.globalParameters["WorkingPath"] == expectedWorkingPath recursiveWorkingPath = "next1" expectedRecurrsiveWorkingPath = "working/path/next1" Common.pushWorkingPath(recursiveWorkingPath) assert Common.globalParameters[ "WorkingPath"] == expectedRecurrsiveWorkingPath Common.popWorkingPath() assert Common.globalParameters["WorkingPath"] == expectedWorkingPath set1WorkingPath = "working/path/set1" expectedSet1WorkingPath = "working/path/set1" Common.setWorkingPath(set1WorkingPath) assert Common.globalParameters["WorkingPath"] == expectedSet1WorkingPath Common.popWorkingPath() assert Common.globalParameters["WorkingPath"] == expectedWorkingPath