Loading tools/TestMacroProcessor/macros/TC.ttcn_macro +6 −2 Original line number Original line Diff line number Diff line type universal charstring Raw; type universal charstring Raw; type universal charstring XsdFile; type record of XsdFile XsdFileList; type port P message { type port P message { inout all; inout all; } } Loading @@ -7,7 +10,8 @@ port P p; port P p; } } external function matchFile(Raw p_textToMatch, charstring p_filePath, out charstring p_matchError) return boolean; external function matchFile(Raw p_textToMatch, XsdFile p_referenceXmlFile, XsdFileList p_xsdFileList, out universal charstring p_matchError) return boolean; // external function matchFile(Raw p_textToMatch, charstring p_filePath, out charstring p_matchError) return boolean; testcase TC_${module}() runs on C system C { testcase TC_${module}() runs on C system C { var Raw v_rcv; var Raw v_rcv; Loading @@ -16,7 +20,7 @@ p.send(m_msg); p.send(m_msg); alt { alt { [] p.check(receive(Raw:?) -> value v_rcv) { [] p.check(receive(Raw:?) -> value v_rcv) { if (matchFile(v_rcv, "${module}.xml", v_matchError)) { if (matchFile(v_rcv, "${module}.xml", ${xsdFileList}, v_matchError)) { alt { alt { [] p.receive(m_msg) { [] p.receive(m_msg) { setverdict(pass); setverdict(pass); Loading tools/TestMacroProcessor/src/TestMacroProcessor.java +20 −2 Original line number Original line Diff line number Diff line Loading @@ -4,6 +4,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; import java.io.IOException; import java.io.InputStreamReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.OutputStreamWriter; Loading Loading @@ -126,7 +127,7 @@ public class TestMacroProcessor { macro = forceMacroGeneration; macro = forceMacroGeneration; } } processedModules.add(moduleName); processedModules.add(moduleName); writeMacro(macro, bw, moduleName); writeMacro(macro, bw, moduleName, inputFile); } else { } else { bw.write(line); bw.write(line); bw.newLine(); bw.newLine(); Loading Loading @@ -156,11 +157,28 @@ public class TestMacroProcessor { return sb.toString(); return sb.toString(); } } private void writeMacro(String macro, BufferedWriter bw, String moduleName) throws IOException { private void writeMacro(String macro, BufferedWriter bw, String moduleName, File inputFile) throws IOException { File macroFile = new File(macroFolder, macro+".ttcn_macro"); File macroFile = new File(macroFolder, macro+".ttcn_macro"); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(macroFile), "UTF-8")); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(macroFile), "UTF-8")); String macroString = readMacro(br); String macroString = readMacro(br); macroString = macroString.replace("${module}", moduleName); macroString = macroString.replace("${module}", moduleName); StringBuilder xsdFileList = new StringBuilder(); xsdFileList.append("{ "); File[] listXSDFiles = inputFile.getParentFile().listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".xsd"); } }); boolean firstFile = true; for (File xsdFile : listXSDFiles) { if (!firstFile) { xsdFileList.append(", "); } firstFile = false; xsdFileList.append("\"").append(xsdFile.getName()).append("\""); } xsdFileList.append(" }"); macroString = macroString.replace("${xsdFileList}", xsdFileList); bw.write(macroString); bw.write(macroString); bw.newLine(); bw.newLine(); try { try { Loading Loading
tools/TestMacroProcessor/macros/TC.ttcn_macro +6 −2 Original line number Original line Diff line number Diff line type universal charstring Raw; type universal charstring Raw; type universal charstring XsdFile; type record of XsdFile XsdFileList; type port P message { type port P message { inout all; inout all; } } Loading @@ -7,7 +10,8 @@ port P p; port P p; } } external function matchFile(Raw p_textToMatch, charstring p_filePath, out charstring p_matchError) return boolean; external function matchFile(Raw p_textToMatch, XsdFile p_referenceXmlFile, XsdFileList p_xsdFileList, out universal charstring p_matchError) return boolean; // external function matchFile(Raw p_textToMatch, charstring p_filePath, out charstring p_matchError) return boolean; testcase TC_${module}() runs on C system C { testcase TC_${module}() runs on C system C { var Raw v_rcv; var Raw v_rcv; Loading @@ -16,7 +20,7 @@ p.send(m_msg); p.send(m_msg); alt { alt { [] p.check(receive(Raw:?) -> value v_rcv) { [] p.check(receive(Raw:?) -> value v_rcv) { if (matchFile(v_rcv, "${module}.xml", v_matchError)) { if (matchFile(v_rcv, "${module}.xml", ${xsdFileList}, v_matchError)) { alt { alt { [] p.receive(m_msg) { [] p.receive(m_msg) { setverdict(pass); setverdict(pass); Loading
tools/TestMacroProcessor/src/TestMacroProcessor.java +20 −2 Original line number Original line Diff line number Diff line Loading @@ -4,6 +4,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; import java.io.IOException; import java.io.InputStreamReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.OutputStreamWriter; Loading Loading @@ -126,7 +127,7 @@ public class TestMacroProcessor { macro = forceMacroGeneration; macro = forceMacroGeneration; } } processedModules.add(moduleName); processedModules.add(moduleName); writeMacro(macro, bw, moduleName); writeMacro(macro, bw, moduleName, inputFile); } else { } else { bw.write(line); bw.write(line); bw.newLine(); bw.newLine(); Loading Loading @@ -156,11 +157,28 @@ public class TestMacroProcessor { return sb.toString(); return sb.toString(); } } private void writeMacro(String macro, BufferedWriter bw, String moduleName) throws IOException { private void writeMacro(String macro, BufferedWriter bw, String moduleName, File inputFile) throws IOException { File macroFile = new File(macroFolder, macro+".ttcn_macro"); File macroFile = new File(macroFolder, macro+".ttcn_macro"); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(macroFile), "UTF-8")); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(macroFile), "UTF-8")); String macroString = readMacro(br); String macroString = readMacro(br); macroString = macroString.replace("${module}", moduleName); macroString = macroString.replace("${module}", moduleName); StringBuilder xsdFileList = new StringBuilder(); xsdFileList.append("{ "); File[] listXSDFiles = inputFile.getParentFile().listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".xsd"); } }); boolean firstFile = true; for (File xsdFile : listXSDFiles) { if (!firstFile) { xsdFileList.append(", "); } firstFile = false; xsdFileList.append("\"").append(xsdFile.getName()).append("\""); } xsdFileList.append(" }"); macroString = macroString.replace("${xsdFileList}", xsdFileList); bw.write(macroString); bw.write(macroString); bw.newLine(); bw.newLine(); try { try { Loading