Ejemplo n.º 1
0
    def runExample(self, lang, extra, types):

        print "RoundTrip - runExample ..."

        if lang == "cs" and not self.host.isWindows():
            print "C# not supported on " + self.host.name
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:

                print "In runExample for " + self.expath + ": " + self.name + ": " + lang

                currPath = os.getcwd()

                try:
                    super(roundtrip, self).setExampleResultDir(lang, extra)

                    if lang == "java":
                        pubName = "Saj_RoundTrip_Pong.jar"
                        subName = "Saj_RoundTrip_Ping.jar"
                    elif lang == "java5":
                        pubName = "pong/java5_pong.jar"
                        subName = "ping/java5_ping.jar"
                    else:
                        pubName = "pong"
                        subName = "ping"

                    with open('examples.json') as data_file:
                        data = json.load(data_file)

                    sub_conds_file = data[self.expath][
                        self.name]["log_conditions_file"][lang]["sub_conds"]
                    pub_conds_file = data[self.expath][
                        self.name]["log_conditions_file"][lang]["pub_conds"]

                    sub_conds = os.path.join(
                        os.path.dirname(os.path.realpath(__file__)), 'yaml',
                        sub_conds_file)
                    pub_conds = os.path.join(
                        os.path.dirname(os.path.realpath(__file__)), 'yaml',
                        pub_conds_file)

                    exSfx = ""

                    if self.host.isWindows() and not "java" in lang:
                        exSfx = ".exe"

                    msg = "NONE"
                    result = "PASS"

                    try:
                        super(roundtrip, self).setLogPathAndLogs(lang, extra)
                        pubLog = os.path.join(self.pPath, 'publisher.log')
                        subLog = os.path.join(self.pPath, 'subscriber.log')

                        pubexe = os.path.join(self.pPath, pubName) + exSfx

                        if os.path.isfile(pubexe):
                            pubThread = ExeThread(self.classpath, pubLog, lang,
                                                  pubexe, "",
                                                  self.example_timeout * 2)
                        else:
                            msg = "MissingExecutable: " + pubexe

                        subexe = os.path.join(self.pPath, subName) + exSfx

                        if os.path.isfile(pubexe):
                            subThread = ExeThread(self.classpath, subLog, lang,
                                                  subexe, self.sub_params,
                                                  self.example_timeout)
                        else:
                            msg = "MissingExecutable: " + subexe

                        quitexe = os.path.join(self.pPath, subName) + exSfx

                        if os.path.isfile(pubexe):
                            quitThread = ExeThread(self.classpath, subLog,
                                                   lang, quitexe,
                                                   self.quit_params,
                                                   self.example_timeout)
                        else:
                            msg = "MissingExecutable: " + quitexe

                        os.chdir(self.pPath)

                        if msg == "NONE":
                            self.startOSPL()
                            print "Starting pubThread for ", pubexe
                            pubThread.start()
                            print "Starting subThread for ", subexe
                            subThread.start()

                            subThread.join(self.example_timeout)
                            print "Starting quitThread for ", quitexe
                            quitThread.start()
                            pubThread.join(self.example_timeout)
                            quitThread.join(self.example_timeout)

                    except Exception:
                        msg = "Exception running " + str(sys.exc_info()[0])

                    try:
                        self.stopOSPL()
                    except Exception as ex:
                        print "Exception stopping OpenSplice ", str(ex)

                    if msg == "NONE":
                        try:
                            super(roundtrip, self).copyLogs()

                            if os.path.isfile(self.ospl_error_log):
                                msg = "ospl-error.log found"
                            #pdb.set_trace()
                            self.checkResults(subLog, sub_conds)
                            self.checkResults(pubLog, pub_conds)

                            self.checkOSPLInfoLog(self.ospl_info_log)

                        except LogCheckFail as lf:
                            reason = str(lf)
                            if "OpenSpliceDDS Warnings" in reason:
                                msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                            else:
                                msg = "LogCheckFail: " + str(lf)
                        except Exception:
                            msg = "Exception checking logs " + str(
                                sys.exc_info()[0])

                    if msg != "NONE":
                        result = "FAIL"

                    try:
                        self.writeResult(result, self.expath + self.name, lang,
                                         msg)
                    except Exception as ex:
                        print "Exception writing result", str(ex)

                    try:
                        self.cleanUp()
                    except Exception as ex:
                        print "Exception cleaning up", str(ex)

                except Exception as ex:
                    print "Unexpected exception ", str(ex)
                finally:
                    os.chdir(currPath)
Ejemplo n.º 2
0
    def runExample(self, lang, extra, types):
        if lang == "cs" and not self.host.isWindows():
            print("C# not supported on " + self.host.name)
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:
                if extra == "all":
                    self.runExampleAllExtra(lang, extra, types)
                else:
                    currPath = os.getcwd()
                    print("In runExample for " + self.expath + ": " +
                          self.name + ": " + lang)

                    try:
                        super(lifecycle, self).setExampleResultDir(lang, extra)

                        with open('examples.json') as data_file:
                            data = json.load(data_file)

                        pubName = data[self.expath][
                            self.name]["executables"][lang]["pubName"]
                        subName = data[self.expath][
                            self.name]["executables"][lang]["subName"]

                        sub_conds_file = data[self.expath][self.name][
                            "log_conditions_file"][lang]["sub_conds"]
                        pub_conds_file = data[self.expath][self.name][
                            "log_conditions_file"][lang]["pub_conds"]

                        sub_conds = os.path.join(
                            os.path.dirname(os.path.realpath(__file__)),
                            'yaml', sub_conds_file)
                        pub_conds = os.path.join(
                            os.path.dirname(os.path.realpath(__file__)),
                            'yaml', pub_conds_file)

                        exSfx = ""

                        if self.host.isWindows() and not "java" in lang:
                            exSfx = ".exe"

                        msg = "NONE"
                        result = "PASS"

                        try:
                            super(lifecycle,
                                  self).setLogPathAndLogs(lang, extra)
                            pub1Log = os.path.join(self.pPath,
                                                   'publisher1.log')
                            pub2Log = os.path.join(self.pPath,
                                                   'publisher2.log')
                            pub3Log = os.path.join(self.pPath,
                                                   'publisher3.log')
                            sub1Log = os.path.join(self.pPath,
                                                   'subscriber1.log')
                            sub2Log = os.path.join(self.pPath,
                                                   'subscriber2.log')
                            sub3Log = os.path.join(self.pPath,
                                                   'subscriber3.log')

                            os.chdir(self.pPath)

                            pubexe = os.path.join(self.pPath, pubName) + exSfx

                            if os.path.isfile(pubexe):
                                pub1Thread = ExeThread(
                                    self.classpath, pub1Log, lang, pubexe,
                                    self.pub1_params, self.example_timeout * 2)
                            else:
                                msg = "MissingExecutable: " + pubexe

                            subexe = os.path.join(self.pPath, subName) + exSfx

                            if os.path.isfile(subexe):
                                sub1Thread = ExeThread(self.classpath, sub1Log,
                                                       lang, subexe,
                                                       self.sub_params,
                                                       self.example_timeout)
                            else:
                                msg = "MissingExecutable: " + subexe

                            if msg == "NONE":
                                self.startOSPL()
                                print("Starting sub1Thread for ", subexe)
                                sub1Thread.start()
                                print("Starting pub1Thread for ", pubexe)
                                pub1Thread.start()

                                pub1Thread.join(self.example_timeout)
                                sub1Thread.join(self.example_timeout)

                        except Exception as ex:
                            msg = "Exception running " + str(ex)

                        self.stopOSPL()

                        if msg == "NONE":
                            pub2Thread = ExeThread(self.classpath, pub2Log,
                                                   lang, pubexe,
                                                   self.pub2_params,
                                                   self.example_timeout * 2)

                            sub2Thread = ExeThread(self.classpath, sub2Log,
                                                   lang, subexe,
                                                   self.sub_params,
                                                   self.example_timeout)

                            self.startOSPL()
                            print("Starting sub2Thread for ", subexe)
                            sub2Thread.start()
                            print("Starting pub2Thread for ", pubexe)
                            pub2Thread.start()

                            pub2Thread.join(self.example_timeout)
                            sub2Thread.join(self.example_timeout)

                            self.stopOSPL()

                            pub3Thread = ExeThread(self.classpath, pub3Log,
                                                   lang, pubexe,
                                                   self.pub3_params,
                                                   self.example_timeout * 2)

                            sub3Thread = ExeThread(self.classpath, sub3Log,
                                                   lang, subexe,
                                                   self.sub_params,
                                                   self.example_timeout)

                            self.startOSPL()
                            print("Starting sub3Thread for ", subexe)
                            sub3Thread.start()
                            print("Starting pub3Thread for ", pubexe)
                            pub3Thread.start()

                            pub3Thread.join(self.example_timeout)
                            sub3Thread.join(self.example_timeout)

                            self.stopOSPL()

                        if msg == "NONE":
                            try:
                                super(lifecycle, self).copyLogs()

                                if os.path.isfile(self.ospl_error_log):
                                    msg = "ospl-error.log found"

                                self.checkResults(sub1Log, sub_conds)
                                self.checkResults(sub2Log, sub_conds)
                                self.checkResults(sub3Log, sub_conds)
                                self.checkResults(pub1Log, pub_conds)
                                self.checkResults(pub2Log, pub_conds)
                                self.checkResults(pub3Log, pub_conds)

                                self.checkOSPLInfoLog(self.ospl_info_log)

                            except LogCheckFail as lf:
                                reason = str(lf)
                                if "OpenSpliceDDS Warnings" in reason:
                                    msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                                else:
                                    msg = "LogCheckFail: " + str(lf)
                            except Exception as ex:
                                msg = "Exception checking logs " + str(ex)

                        if msg != "NONE":
                            result = "FAIL"

                        try:
                            self.writeResult(result, self.expath + self.name,
                                             lang, msg)
                        except Exception as ex:
                            print("Exception checking logs ", str(ex))

                        if self.host.isWindows():
                            time.sleep(5)

                        try:
                            self.cleanUp()
                        except Exception as ex:
                            print("Exception cleaning up ", str(ex))

                    except Exception as ex:
                        print("Unexpected exception ", str(ex))

                    finally:
                        os.chdir(currPath)
Ejemplo n.º 3
0
    def runExample(self, lang, extra, types):
        if lang == "cs" and not self.host.isWindows():
            print("C# not supported on " + self.host.name)
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:
                if extra == "all":
                    self.runExampleAllExtra(lang, extra, types)
                else:
                    print("In runExample for " + self.expath + ": " +
                          self.name + ": " + lang + ":" + extra)

                    currPath = os.getcwd()

                    try:
                        super(tutorial, self).setExampleResultDir(lang, extra)

                        with open('examples.json') as data_file:
                            data = json.load(data_file)

                        msgBoardName = data[self.expath][
                            self.name]["executables"][lang]["msgBoardName"]
                        chatterName = data[self.expath][
                            self.name]["executables"][lang]["chatterName"]
                        userLoadName = data[self.expath][
                            self.name]["executables"][lang]["userLoadName"]

                        msgboard_conds_file = data[self.expath][self.name][
                            "log_conditions_file"][lang]["msgboard_conds"]
                        chatter_conds_file = data[self.expath][self.name][
                            "log_conditions_file"][lang]["chatter_conds"]

                        msgboard_conds = os.path.join(
                            os.path.dirname(os.path.realpath(__file__)),
                            'yaml', msgboard_conds_file)
                        chatter_conds = os.path.join(
                            os.path.dirname(os.path.realpath(__file__)),
                            'yaml', chatter_conds_file)

                        exSfx = ""

                        if self.host.isWindows() and not "java" in lang:
                            exSfx = ".exe"

                        msg = "NONE"
                        result = "PASS"

                        try:
                            self.setLogPathAndLogs(lang, extra)
                            msgBoardLog = os.path.join(self.pPath,
                                                       'msgBoard.log')
                            chatterLog = os.path.join(self.pPath,
                                                      'chatter.log')
                            userLoadLog = os.path.join(self.pPath,
                                                       'userLoad.log')

                            if extra == "corba" and lang == "java":
                                ospljar = os.path.join(os.environ['OSPL_HOME'],
                                                       "jar", "dcpscj.jar")
                                classes = os.path.join(os.environ['OSPL_HOME'],
                                                       "examples", self.expath,
                                                       self.name, lang, extra,
                                                       "classes")
                                self.classpath = ospljar + os.pathsep + classes
                                runLang = "cj"
                            else:
                                runLang = lang

                            with open('examples.json') as data_file:
                                data = json.load(data_file)

                            if extra == "corba":
                                exes = "corba_executables"
                            else:
                                exes = "executables"

                            msgBoardName = data[self.expath][
                                self.name][exes][lang]["msgBoardName"]
                            chatterName = data[self.expath][
                                self.name][exes][lang]["chatterName"]
                            userLoadName = data[self.expath][
                                self.name][exes][lang]["userLoadName"]

                            if msgBoardName != "":
                                if self.classpath == "" and runLang is not "cj":
                                    msgBoardExe = os.path.join(
                                        self.pPath, msgBoardName) + exSfx
                                    if not os.path.isfile(msgBoardExe):
                                        msg = "MissingExecutable: " + msgBoardExe
                                else:
                                    msgBoardExe = msgBoardName

                            if userLoadName != "":
                                if self.classpath == "" and runLang is not "cj":
                                    userLoadExe = os.path.join(
                                        self.pPath, userLoadName) + exSfx
                                    if not os.path.isfile(userLoadExe):
                                        msg = "MissingExecutable: " + userLoadExe
                                else:
                                    userLoadExe = userLoadName

                            if chatterName != "":
                                if self.classpath == "" and runLang is not "cj":
                                    chatterExe = os.path.join(
                                        self.pPath, chatterName) + exSfx
                                    chatterquitExe = os.path.join(
                                        self.pPath, chatterName) + exSfx
                                    if not os.path.isfile(chatterExe):
                                        msg = "MissingExecutable: " + chatterExe
                                else:
                                    chatterExe = chatterName
                                    chatterquitExe = chatterName

                            if msg == "NONE":
                                msgBoardThread = ExeThread(
                                    self.classpath, msgBoardLog, runLang,
                                    msgBoardExe, self.msgboard_params,
                                    self.example_timeout * 2)
                                userLoadThread = ExeThread(
                                    self.classpath, userLoadLog, runLang,
                                    userLoadExe, "", self.example_timeout * 2)
                                chatterThread = ExeThread(
                                    self.classpath, chatterLog, runLang,
                                    chatterExe, self.chatter_params,
                                    self.example_timeout)
                                quitThread = ExeThread(self.classpath,
                                                       chatterLog, runLang,
                                                       chatterquitExe,
                                                       self.quit_params,
                                                       self.example_timeout)

                                os.chdir(self.pPath)

                                self.startOSPL()
                                msgBoardThread.start()
                                #Allow time for the message board to get started...
                                time.sleep(5)
                                userLoadThread.start()
                                chatterThread.start()

                                chatterThread.join(self.example_timeout)

                                quitThread.start()
                                msgBoardThread.join(self.example_timeout)
                                userLoadThread.join(self.example_timeout)
                                quitThread.join(self.example_timeout)

                        except Exception:
                            msg = "Exception running " + str(sys.exc_info()[0])

                        try:
                            self.stopOSPL()
                        except Exception as ex:
                            print("Exception stopping OpenSplice ", str(ex))

                        if msg == "NONE":
                            try:
                                super(tutorial, self).copyLogs()

                                if os.path.isfile(self.ospl_error_log):
                                    msg = "ospl-error.log found"

                                self.checkResults(msgBoardLog, msgboard_conds)
                                self.checkResults(chatterLog, chatter_conds)

                                self.checkOSPLInfoLog(self.ospl_info_log)

                            except LogCheckFail as lf:
                                reason = str(lf)
                                if "OpenSpliceDDS Warnings" in reason:
                                    msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                                else:
                                    msg = "LogCheckFail: " + str(lf)
                            except Exception:
                                msg = "Exception checking logs " + str(
                                    sys.exc_info()[0])

                        if msg != "NONE":
                            result = "FAIL"

                        resultLang = lang

                        if extra == "corba":
                            if lang == "cpp":
                                resultLang = "ccpp"
                            elif lang == "java":
                                resultLang = "cj"

                        try:
                            self.writeResult(result, self.expath + self.name,
                                             resultLang, msg)
                        except Exception as ex:
                            print("Exception writing result", str(ex))

                        try:
                            self.cleanUp()
                        except Exception as ex:
                            print("Exception cleaning up", str(ex))

                    except Exception as ex:
                        print("Unexpected exception ", str(ex))
                    finally:
                        os.chdir(currPath)
Ejemplo n.º 4
0
    def runExample(self, lang, extra, types):

        print "RoundTrip - runExample ..."

        if lang == "cs" and not self.host.isWindows():
            print "C# not supported on " + self.host.name
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:

                print "In runExample for " + self.expath + ": " + self.name + ": " + lang

                currPath = os.getcwd()

                try:
                    super(roundtrip, self).setExampleResultDir(lang, extra)

                    if lang == "java":
                        pubName = "Saj_RoundTrip_Pong.jar"
                        subName = "Saj_RoundTrip_Ping.jar"
                    elif lang == "java5":
                        pubName = "pong/java5_pong.jar"
                        subName = "ping/java5_ping.jar"
                    else:
                        pubName = "pong"
                        subName = "ping"

                    with open ('examples.json') as data_file:
                        data = json.load(data_file)

                    sub_conds_file = data[self.expath][self.name]["log_conditions_file"][lang]["sub_conds"]
                    pub_conds_file = data[self.expath][self.name]["log_conditions_file"][lang]["pub_conds"]

                    sub_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', sub_conds_file)
                    pub_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', pub_conds_file)

                    exSfx = ""

                    if self.host.isWindows() and not "java" in lang:
                        exSfx = ".exe"

                    msg = "NONE"
                    result = "PASS"

                    try:
                        super(roundtrip, self).setLogPathAndLogs(lang, extra)
                        pubLog = os.path.join(self.pPath, 'publisher.log')
                        subLog = os.path.join(self.pPath, 'subscriber.log')

                        pubexe = os.path.join(self.pPath, pubName) + exSfx

                        if os.path.isfile (pubexe):
                            pubThread = ExeThread(self.classpath, pubLog, lang, pubexe, "", self.example_timeout * 2)
                        else:
                            msg = "MissingExecutable: " + pubexe

                        subexe = os.path.join(self.pPath, subName) + exSfx

                        if os.path.isfile (pubexe):
                            subThread = ExeThread(self.classpath, subLog, lang, subexe, self.sub_params, self.example_timeout)
                        else:
                            msg = "MissingExecutable: " + subexe

                        quitexe = os.path.join(self.pPath, subName) + exSfx

                        if os.path.isfile (pubexe):
                            quitThread = ExeThread(self.classpath, subLog, lang, quitexe, self.quit_params, self.example_timeout)
                        else:
                            msg = "MissingExecutable: " + quitexe

                        os.chdir(self.pPath)

                        if msg == "NONE":
                            self.startOSPL()
                            print "Starting pubThread for ", pubexe
                            pubThread.start()
                            print "Starting subThread for ", subexe
                            subThread.start()

                            subThread.join(self.example_timeout)
                            print "Starting quitThread for ", quitexe
                            quitThread.start()
                            pubThread.join(self.example_timeout)
                            quitThread.join(self.example_timeout)

                    except Exception:
                        msg = "Exception running " + str(sys.exc_info()[0])

                    try:
                        self.stopOSPL()
                    except Exception as ex:
                        print "Exception stopping OpenSplice ", str(ex)

                    if msg == "NONE":
                        try:
                            super(roundtrip, self).copyLogs()

                            if os.path.isfile (self.ospl_error_log):
                                msg = "ospl-error.log found"
                            #pdb.set_trace()
                            self.checkResults(subLog, sub_conds)
                            self.checkResults(pubLog, pub_conds)

                            self.checkOSPLInfoLog(self.ospl_info_log)

                        except LogCheckFail as lf:
                            reason = str(lf)
                            if "OpenSpliceDDS Warnings" in reason:
                                msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                            else:
                                msg = "LogCheckFail: " + str(lf)
                        except Exception:
                            msg = "Exception checking logs " + str(sys.exc_info()[0])

                    if msg != "NONE":
                        result = "FAIL"

                    try:
                        self.writeResult (result,  self.expath +  self.name, lang, msg)
                    except Exception as ex:
                        print "Exception writing result", str(ex)

                    try:
                        self.cleanUp()
                    except Exception as ex:
                        print "Exception cleaning up", str(ex)

                except Exception as ex:
                    print "Unexpected exception ", str(ex)
                finally:
                    os.chdir(currPath)
Ejemplo n.º 5
0
    def runExample(self, lang, extra, types):
        if lang == "cs" and not self.host.isWindows():
            print "C# not supported on " + self.host.name
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:
                if extra == "all":
                    self.runExampleAllExtra(lang, extra, types)
                else:
                    currPath = os.getcwd()
                    print "In runExample for " + self.expath + ": " + self.name + ": " + lang

                    try:
                        super(lifecycle, self).setExampleResultDir(lang, extra)

                        with open ('examples.json') as data_file:
                            data = json.load(data_file)

                        pubName = data[self.expath][self.name]["executables"][lang]["pubName"]
                        subName = data[self.expath][self.name]["executables"][lang]["subName"]

                        sub_conds_file = data[self.expath][self.name]["log_conditions_file"][lang]["sub_conds"]
                        pub_conds_file = data[self.expath][self.name]["log_conditions_file"][lang]["pub_conds"]

                        sub_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', sub_conds_file)
                        pub_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', pub_conds_file)

                        exSfx = ""

                        if self.host.isWindows() and not "java" in lang:
                            exSfx = ".exe"

                        msg = "NONE"
                        result = "PASS"

                        try:
                            super(lifecycle, self).setLogPathAndLogs(lang, extra)
                            pub1Log = os.path.join(self.pPath, 'publisher1.log')
                            pub2Log = os.path.join(self.pPath, 'publisher2.log')
                            pub3Log = os.path.join(self.pPath, 'publisher3.log')
                            sub1Log = os.path.join(self.pPath, 'subscriber1.log')
                            sub2Log = os.path.join(self.pPath, 'subscriber2.log')
                            sub3Log = os.path.join(self.pPath, 'subscriber3.log')

                            os.chdir(self.pPath)

                            pubexe = os.path.join(self.pPath, pubName) + exSfx

                            if os.path.isfile (pubexe):
                                pub1Thread = ExeThread(self.classpath, pub1Log, lang, pubexe, self.pub1_params, self.example_timeout * 2)
                            else:
                                msg = "MissingExecutable: " + pubexe

                            subexe = os.path.join(self.pPath, subName) + exSfx

                            if os.path.isfile (subexe):
                                sub1Thread = ExeThread(self.classpath, sub1Log, lang, subexe, self.sub_params, self.example_timeout)
                            else:
                                msg = "MissingExecutable: " + subexe

                            if msg == "NONE":
                                self.startOSPL()
                                print "Starting sub1Thread for ", subexe
                                sub1Thread.start()
                                print "Starting pub1Thread for ", pubexe
                                pub1Thread.start()

                                pub1Thread.join(self.example_timeout)
                                sub1Thread.join(self.example_timeout)

                        except Exception as ex:
                            msg = "Exception running " + str(ex)

                        self.stopOSPL()

                        if msg == "NONE":
                            pub2Thread = ExeThread(self.classpath, pub2Log, lang, pubexe, self.pub2_params, self.example_timeout * 2)

                            sub2Thread = ExeThread(self.classpath, sub2Log, lang, subexe, self.sub_params, self.example_timeout)

                            self.startOSPL()
                            print "Starting sub2Thread for ", subexe
                            sub2Thread.start()
                            print "Starting pub2Thread for ", pubexe
                            pub2Thread.start()

                            pub2Thread.join(self.example_timeout)
                            sub2Thread.join(self.example_timeout)

                            self.stopOSPL()

                            pub3Thread = ExeThread(self.classpath, pub3Log, lang, pubexe, self.pub3_params, self.example_timeout * 2)

                            sub3Thread = ExeThread(self.classpath, sub3Log, lang, subexe, self.sub_params, self.example_timeout)

                            self.startOSPL()
                            print "Starting sub3Thread for ", subexe
                            sub3Thread.start()
                            print "Starting pub3Thread for ", pubexe
                            pub3Thread.start()

                            pub3Thread.join(self.example_timeout)
                            sub3Thread.join(self.example_timeout)

                            self.stopOSPL()

                        if msg == "NONE":
                            try:
                                super(lifecycle, self).copyLogs()

                                if os.path.isfile (self.ospl_error_log):
                                    msg = "ospl-error.log found"

                                self.checkResults(sub1Log, sub_conds)
                                self.checkResults(sub2Log, sub_conds)
                                self.checkResults(sub3Log, sub_conds)
                                self.checkResults(pub1Log, pub_conds)
                                self.checkResults(pub2Log, pub_conds)
                                self.checkResults(pub3Log, pub_conds)

                                self.checkOSPLInfoLog(self.ospl_info_log)

                            except LogCheckFail as lf:
                                reason = str(lf)
                                if "OpenSpliceDDS Warnings" in reason:
                                    msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                                else:
                                    msg = "LogCheckFail: " + str(lf)
                            except Exception as ex:
                                msg = "Exception checking logs " + str(ex)

                        if msg != "NONE":
                            result = "FAIL"

                        try:
                            self.writeResult (result,  self.expath +  self.name, lang, msg)
                        except Exception as ex:
                            print "Exception checking logs ", str(ex)

                        if self.host.isWindows():
                            time.sleep(5)

                        try:
                            self.cleanUp()
                        except Exception as ex:
                            print "Exception cleaning up ", str(ex)

                    except Exception as ex:
                        print "Unexpected exception ", str(ex)

                    finally:
                        os.chdir(currPath)
Ejemplo n.º 6
0
    def runExample(self):

        print "In runExample for " + self.expath + ": " + self.name

        currPath = os.getcwd()

        try:
            self.exdir = "servicesdbmsconnectSQLCPPODBC"

            exSfx = ""
  
            if self.host.isWindows():
                exSfx = ".exe"
                os.putenv("ODBC_LIB_NAME", "odbc32")
            else:
                os.putenv("ODBC_LIB_NAME", "odbc")

            msg = "NONE"
            result = "PASS"

            dsn = self.odbcMsgBoard_params[0]
            os.putenv("MY_DSN", dsn);
            os.environ["MY_DSN"]= dsn;

            os.putenv("OSPL_URI", self.uri)
            os.environ["OSPL_URI"] = self.uri
            
            try:
                self.convertConfig()

                self.setLogPathAndLogs("", "")
                odbcMsgBoardLog = os.path.join(self.pPath, 'odbcMsgBoard.log')
                odbcChatter1Log = os.path.join(self.pPath, 'odbcChatter1.log')
                odbcChatter2Log = os.path.join(self.pPath, 'odbcChatter2.log')
                odbcChatterQuitLog = os.path.join(self.pPath, 'odbcChatterQuit.log')
                cppMsgBoardLog = os.path.join(self.pPath, 'cppMsgBoard.log')
                cppChatter1Log = os.path.join(self.pPath, 'cppChatter1.log')
                cppChatter2Log = os.path.join(self.pPath, 'cppChatter2.log')
                cppChatterQuitLog = os.path.join(self.pPath, 'cppChatterQuit.log')

                with open ('examples.json') as data_file:
                    data = json.load(data_file)

                odbcMsgBoardName = data[self.expath][self.name]["executables"]["odbc"]["msgBoardName"]
                odbcChatterName = data[self.expath][self.name]["executables"]["odbc"]["chatterName"]
                cppMsgBoardName = data[self.expath][self.name]["executables"]["cpp"]["msgBoardName"]
                cppChatterName = data[self.expath][self.name]["executables"]["cpp"]["chatterName"]

                odbcmsgboard_conds_file = data[self.expath][self.name]["log_conditions_file"]["odbcmsgboard_conds"]
                cppmsgboard_conds_file = data[self.expath][self.name]["log_conditions_file"]["msgboard_conds"]
                odbcchatter_conds_file = data[self.expath][self.name]["log_conditions_file"]["odbcchatter_conds"]
                chatter_conds_file = data[self.expath][self.name]["log_conditions_file"]["chatter_conds"]

                odbcmsgboard_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', odbcmsgboard_conds_file)
                odbcchatter_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', odbcchatter_conds_file)
                cppmsgboard_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', cppmsgboard_conds_file)
                cppchatter_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', chatter_conds_file)

                if odbcMsgBoardName != "":
                    if self.classpath == "":
                        odbcMsgBoardExe = os.path.join(self.pPath, odbcMsgBoardName) + exSfx
                        if not os.path.isfile (odbcMsgBoardExe):
                            msg = "MissingExecutable: " + odbcMsgBoardExe
                    else:
                        odbcMsgBoardExe = odbcMsgBoardName

                if odbcChatterName != "":
                    if self.classpath == "":
                        odbcChatterNameExe = os.path.join(self.pPath, odbcChatterName) + exSfx
                        if not os.path.isfile (odbcChatterNameExe):
                            msg = "MissingExecutable: " + odbcChatterNameExe
                    else:
                        odbcChatterNameExe = odbcChatterName

                cppPath = os.path.join(os.environ['OSPL_HOME'], 'examples', "dcps", "Tutorial", "cpp", "standalone")

                if cppMsgBoardName != "":
                    if self.classpath == "":
                        cppMsgBoardExe = os.path.join(cppPath, cppMsgBoardName) + exSfx
                        if not os.path.isfile (cppMsgBoardExe):
                            msg = "MissingExecutable: " + cppMsgBoardExe
                    else:
                        cppMsgBoardExe = cppMsgBoardName

                if cppChatterName != "":
                    if self.classpath == "":
                        cppChatterNameExe = os.path.join(cppPath, cppChatterName) + exSfx
                        if not os.path.isfile (cppChatterNameExe):
                            msg = "MissingExecutable: " + cppChatterNameExe
                    else:
                        cppChatterNameExe = cppChatterName

                if msg == "NONE":  
                    odbcMsgBoard_Thread = ExeThread(self.classpath, odbcMsgBoardLog, "", odbcMsgBoardExe, self.odbcMsgBoard_params, self.example_timeout * 2)
                    odbcChatter1_Thread = ExeThread(self.classpath, odbcChatter1Log, "", odbcChatterNameExe, self.odbcChatter1_params, self.example_timeout)
                    odbcChatter2_Thread = ExeThread(self.classpath, odbcChatter2Log, "", odbcChatterNameExe, self.odbcChatter2_params, self.example_timeout)
                    cppMsgBoard_Thread = ExeThread(self.classpath, cppMsgBoardLog, "", cppMsgBoardExe, "", self.example_timeout * 2)

                    cppChatter1_Thread = ExeThread(self.classpath, cppChatter1Log, "", cppChatterNameExe, self.cppChatter1_params, self.example_timeout)
                    cppChatter2_Thread = ExeThread(self.classpath, cppChatter2Log, "", cppChatterNameExe, self.cppChatter2_params, self.example_timeout)

                    odbcChatterQuit_Thread = ExeThread(self.classpath, odbcChatterQuitLog, "", odbcChatterNameExe, self.odbcChatterQuit_params, self.example_timeout)
                    cppChatterQuit_Thread = ExeThread(self.classpath, cppChatterQuitLog, "", cppChatterNameExe, self.cppChatterQuit_params, self.example_timeout)
 
                    os.chdir(self.pPath)   
   
                    self.startOSPL()

                    cppMsgBoard_Thread.start()
                    odbcMsgBoard_Thread.start()                                            
                    time.sleep(5)
                    odbcChatter1_Thread.start()
                    odbcChatter2_Thread.start()
                    cppChatter1_Thread.start()
                    cppChatter2_Thread.start()

                    odbcChatter1_Thread.join(self.example_timeout)
                    odbcChatter2_Thread.join(self.example_timeout)
                    cppChatter1_Thread.join(self.example_timeout)
                    cppChatter2_Thread.join(self.example_timeout)

                    time.sleep(10)
                    odbcChatterQuit_Thread.start()
                    cppChatterQuit_Thread.start()

                    odbcChatterQuit_Thread.join(self.example_timeout)
                    cppChatterQuit_Thread.join(self.example_timeout)
                    cppMsgBoard_Thread.join(self.example_timeout)
                    odbcMsgBoard_Thread.join(self.example_timeout)  

            except Exception as ex:
                msg = "Exception running ", str(ex)

            try:
                self.stopOSPL()
            except Exception as ex:
                print "Exception stopping OpenSplice ", str(ex)

            if msg == "NONE":
                try:
                    #Allow time for all messages to be written to log
                    time.sleep (15)
                    super(dbmsconnect, self).copyLogs()

                    if os.path.isfile (self.ospl_error_log):
                        msg = "ospl-error.log found"
                             
                    print "checking odbcMsgBoardLog with odbcmsgboard_conds", odbcMsgBoardLog, odbcmsgboard_conds
                    self.checkResults(odbcMsgBoardLog, odbcmsgboard_conds)

                    print "checking odbcChatter1Log with odbcchatter_conds", odbcChatter1Log, odbcchatter_conds
                    self.checkResults(odbcChatter1Log, odbcchatter_conds)

                    print "checking odbcChatter2Log with odbcchatter_conds", odbcChatter2Log, odbcchatter_conds
                    self.checkResults(odbcChatter2Log, odbcchatter_conds)

                    self.checkResults(cppMsgBoardLog, cppmsgboard_conds)
                    self.checkResults(cppChatter1Log, cppchatter_conds)
                    self.checkResults(cppChatter2Log, cppchatter_conds)

                    self.checkOSPLInfoLog(self.ospl_info_log)
                except LogCheckFail as lf:
                    reason = str(lf)
                    if "OpenSpliceDDS Warnings" in reason:
                        msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                    else:
                        msg = "LogCheckFail: " + str(lf)
                except Exception:
                    msg = "Exception checking logs " + str(sys.exc_info()[0])
         
                logdir =  os.path.join(os.environ['LOGDIR'], "examples", "run_" + os.environ['EXRUNTYPE'], self.exdir)
                dbmsconnLog = os.path.join(self.pPath, 'dbmsconnect.log')
                print "dbmsconnect.log is ", dbmsconnLog
                copy(dbmsconnLog, logdir)

                
            if msg != "NONE":
                result = "FAIL"

            try:
                self.writeResult (result,  self.exdir, "", msg)
            except Exception as ex:
                print "Exception writing result", str(ex)

            try:
                self.cleanUp()
            except Exception as ex:
                print "Exception cleaning  up", str(ex)

        except Exception as ex:
            print "Unexpected exception ", str(ex)   
        finally:
            os.chdir(currPath)
Ejemplo n.º 7
0
    def runExample(self, lang, extra, types):
        if lang == "cs" and not self.host.isWindows():
            print "C# not supported on " + self.host.name
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else: 
                if extra == "all":
                    self.runExampleAllExtra(lang, extra, types)
                else:
                    print "In runExample for " + self.expath + ": " + self.name + ": " + lang + ":" + extra

                    currPath = os.getcwd()

                    try:
                        super(tutorial, self).setExampleResultDir(lang, extra)

                        with open ('examples.json') as data_file:
                            data = json.load(data_file)

                        msgBoardName = data[self.expath][self.name]["executables"][lang]["msgBoardName"]
                        chatterName = data[self.expath][self.name]["executables"][lang]["chatterName"]
                        userLoadName = data[self.expath][self.name]["executables"][lang]["userLoadName"]

                        msgboard_conds_file = data[self.expath][self.name]["log_conditions_file"][lang]["msgboard_conds"]
                        chatter_conds_file = data[self.expath][self.name]["log_conditions_file"][lang]["chatter_conds"]

                        msgboard_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', msgboard_conds_file)
                        chatter_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', chatter_conds_file)

                        exSfx = ""
      
                        if self.host.isWindows() and not "java" in lang:
                            exSfx = ".exe"
  
                        msg = "NONE"
                        result = "PASS"

                        try:
                            self.setLogPathAndLogs(lang, extra)
                            msgBoardLog = os.path.join(self.pPath, 'msgBoard.log')
                            chatterLog = os.path.join(self.pPath, 'chatter.log')
                            userLoadLog = os.path.join(self.pPath, 'userLoad.log')

                            if extra == "corba" and lang == "java":
                                ospljar = os.path.join(os.environ['OSPL_HOME'], "jar", "dcpscj.jar")
                                classes = os.path.join(os.environ['OSPL_HOME'], "examples", self.expath, self.name, lang, extra, "classes")
                                self.classpath = ospljar + os.pathsep + classes
                                runLang = "cj"
                            else:
                                runLang = lang

                            with open ('examples.json') as data_file:
                                data = json.load(data_file)

                            if extra == "corba":
                                exes = "corba_executables"
                            else:
                                exes = "executables"

                            msgBoardName = data[self.expath][self.name][exes][lang]["msgBoardName"]
                            chatterName  = data[self.expath][self.name][exes][lang]["chatterName"]
                            userLoadName = data[self.expath][self.name][exes][lang]["userLoadName"]

                            if msgBoardName != "":
                                if self.classpath == "" and runLang is not "cj":
                                    msgBoardExe = os.path.join(self.pPath, msgBoardName) + exSfx
                                    if not os.path.isfile (msgBoardExe):
                                        msg = "MissingExecutable: " + msgBoardExe
                                else:
                                    msgBoardExe = msgBoardName

                            if userLoadName != "":
                                if self.classpath == "" and runLang is not "cj":
                                    userLoadExe = os.path.join(self.pPath, userLoadName) + exSfx
                                    if not os.path.isfile (userLoadExe):
                                        msg = "MissingExecutable: " + userLoadExe
                                else:
                                    userLoadExe = userLoadName

                            if chatterName != "":
                                if self.classpath == "" and runLang is not "cj":
                                    chatterExe = os.path.join(self.pPath, chatterName) + exSfx
                                    chatterquitExe = os.path.join(self.pPath, chatterName) + exSfx
                                    if not os.path.isfile (chatterExe):
                                        msg = "MissingExecutable: " + chatterExe
                                else:
                                    chatterExe = chatterName
                                    chatterquitExe = chatterName

                            if msg == "NONE":  
                                msgBoardThread = ExeThread(self.classpath, msgBoardLog, runLang, msgBoardExe, self.msgboard_params, self.example_timeout * 2)
                                userLoadThread = ExeThread(self.classpath, userLoadLog, runLang, userLoadExe, "", self.example_timeout * 2)
                                chatterThread = ExeThread(self.classpath, chatterLog, runLang, chatterExe, self.chatter_params, self.example_timeout) 
                                quitThread = ExeThread(self.classpath, chatterLog, runLang, chatterquitExe, self.quit_params, self.example_timeout)
   
                                os.chdir(self.pPath)   

                                self.startOSPL()
                                msgBoardThread.start()
                                #Allow time for the message board to get started...
                                time.sleep(5)
                                userLoadThread.start()
                                chatterThread.start()
                                            
                                chatterThread.join(self.example_timeout)

                                quitThread.start()
                                msgBoardThread.join(self.example_timeout)
                                userLoadThread.join(self.example_timeout)
                                quitThread.join(self.example_timeout)                        

                        except Exception:
                            msg = "Exception running " + str(sys.exc_info()[0])

                        try:
                            self.stopOSPL()
                        except Exception as ex:
                            print "Exception stopping OpenSplice ", str(ex)

                        if msg == "NONE":
                            try:
                                super(tutorial, self).copyLogs()

                                if os.path.isfile (self.ospl_error_log):
                                    msg = "ospl-error.log found"
                             
                                self.checkResults(msgBoardLog, msgboard_conds)
                                self.checkResults(chatterLog, chatter_conds)

                                self.checkOSPLInfoLog(self.ospl_info_log)

                            except LogCheckFail as lf:
                                reason = str(lf)
                                if "OpenSpliceDDS Warnings" in reason:
                                    msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                                else:
                                    msg = "LogCheckFail: " + str(lf)
                            except Exception:
                                msg = "Exception checking logs " + str(sys.exc_info()[0])

                        if msg != "NONE":
                            result = "FAIL"

                        resultLang = lang

                        if extra == "corba":
                            if lang == "cpp":
                                resultLang = "ccpp"
                            elif lang == "java":
                                resultLang = "cj"

                        try:
                            self.writeResult (result,  self.expath + self.name, resultLang, msg)
                        except Exception as ex:
                            print "Exception writing result", str(ex)

                        try:
                            self.cleanUp()
                        except Exception as ex:
                            print "Exception cleaning up", str(ex)

                    except Exception as ex:
                        print "Unexpected exception ", str(ex)
                    finally:
                        os.chdir(currPath)   
Ejemplo n.º 8
0
    def runExample(self):

        print("In runExample for " + self.expath + ": " + self.name)

        currPath = os.getcwd()

        try:

            self.exdir = "servicesdbmsconnectSQLCPPODBC"

            exSfx = ""

            if self.host.isWindows():
                exSfx = ".exe"
                os.putenv("ODBC_LIB_NAME", "odbc32")
            else:
                os.putenv("ODBC_LIB_NAME", "odbc")

            msg = "NONE"
            result = "PASS"

            os.putenv("OSPL_URI", self.uri)
            os.environ["OSPL_URI"] = self.uri

            try:
                self.setLogPathAndLogs("", "")
                odbcMsgBoardLog = os.path.join(self.pPath, 'odbcMsgBoard.log')
                odbcChatter1Log = os.path.join(self.pPath, 'odbcChatter1.log')
                odbcChatter2Log = os.path.join(self.pPath, 'odbcChatter2.log')
                odbcChatterQuitLog = os.path.join(self.pPath,
                                                  'odbcChatterQuit.log')
                cppMsgBoardLog = os.path.join(self.pPath, 'cppMsgBoard.log')
                cppChatter1Log = os.path.join(self.pPath, 'cppChatter1.log')
                cppChatter2Log = os.path.join(self.pPath, 'cppChatter2.log')
                cppChatterQuitLog = os.path.join(self.pPath,
                                                 'cppChatterQuit.log')

                with open('examples.json') as data_file:
                    data = json.load(data_file)

                odbcMsgBoardName = data[self.expath][
                    self.name]["executables"]["odbc"]["msgBoardName"]
                odbcChatterName = data[self.expath][
                    self.name]["executables"]["odbc"]["chatterName"]
                cppMsgBoardName = data[self.expath][
                    self.name]["executables"]["cpp"]["msgBoardName"]
                cppChatterName = data[self.expath][
                    self.name]["executables"]["cpp"]["chatterName"]

                odbcmsgboard_conds_file = data[self.expath][
                    self.name]["log_conditions_file"]["odbcmsgboard_conds"]
                cppmsgboard_conds_file = data[self.expath][
                    self.name]["log_conditions_file"]["msgboard_conds"]
                odbcchatter_conds_file = data[self.expath][
                    self.name]["log_conditions_file"]["odbcchatter_conds"]
                chatter_conds_file = data[self.expath][
                    self.name]["log_conditions_file"]["chatter_conds"]

                odbcmsgboard_conds = os.path.join(
                    os.path.dirname(os.path.realpath(__file__)), 'yaml',
                    odbcmsgboard_conds_file)
                odbcchatter_conds = os.path.join(
                    os.path.dirname(os.path.realpath(__file__)), 'yaml',
                    odbcchatter_conds_file)
                cppmsgboard_conds = os.path.join(
                    os.path.dirname(os.path.realpath(__file__)), 'yaml',
                    cppmsgboard_conds_file)
                cppchatter_conds = os.path.join(
                    os.path.dirname(os.path.realpath(__file__)), 'yaml',
                    chatter_conds_file)

                if odbcMsgBoardName != "":
                    if self.classpath == "":
                        odbcMsgBoardExe = os.path.join(
                            self.pPath, odbcMsgBoardName) + exSfx
                        if not os.path.isfile(odbcMsgBoardExe):
                            msg = "MissingExecutable: " + odbcMsgBoardExe
                    else:
                        odbcMsgBoardExe = odbcMsgBoardName

                if odbcChatterName != "":
                    if self.classpath == "":
                        odbcChatterNameExe = os.path.join(
                            self.pPath, odbcChatterName) + exSfx
                        if not os.path.isfile(odbcChatterNameExe):
                            msg = "MissingExecutable: " + odbcChatterNameExe
                    else:
                        odbcChatterNameExe = odbcChatterName

                cppPath = os.path.join(os.environ['OSPL_HOME'], 'examples',
                                       "dcps", "Tutorial", "cpp", "standalone")

                if cppMsgBoardName != "":
                    if self.classpath == "":
                        cppMsgBoardExe = os.path.join(cppPath,
                                                      cppMsgBoardName) + exSfx
                        if not os.path.isfile(cppMsgBoardExe):
                            msg = "MissingExecutable: " + cppMsgBoardExe
                    else:
                        cppMsgBoardExe = cppMsgBoardName

                if cppChatterName != "":
                    if self.classpath == "":
                        cppChatterNameExe = os.path.join(
                            cppPath, cppChatterName) + exSfx
                        if not os.path.isfile(cppChatterNameExe):
                            msg = "MissingExecutable: " + cppChatterNameExe
                    else:
                        cppChatterNameExe = cppChatterName

                if msg == "NONE":
                    odbcMsgBoard_Thread = ExeThread(self.classpath,
                                                    odbcMsgBoardLog, "",
                                                    odbcMsgBoardExe,
                                                    self.odbcMsgBoard_params,
                                                    self.example_timeout * 2)
                    odbcChatter1_Thread = ExeThread(self.classpath,
                                                    odbcChatter1Log, "",
                                                    odbcChatterNameExe,
                                                    self.odbcChatter1_params,
                                                    self.example_timeout)
                    odbcChatter2_Thread = ExeThread(self.classpath,
                                                    odbcChatter2Log, "",
                                                    odbcChatterNameExe,
                                                    self.odbcChatter2_params,
                                                    self.example_timeout)
                    cppMsgBoard_Thread = ExeThread(self.classpath,
                                                   cppMsgBoardLog, "",
                                                   cppMsgBoardExe, "",
                                                   self.example_timeout * 2)

                    cppChatter1_Thread = ExeThread(self.classpath,
                                                   cppChatter1Log, "",
                                                   cppChatterNameExe,
                                                   self.cppChatter1_params,
                                                   self.example_timeout)
                    cppChatter2_Thread = ExeThread(self.classpath,
                                                   cppChatter2Log, "",
                                                   cppChatterNameExe,
                                                   self.cppChatter2_params,
                                                   self.example_timeout)

                    odbcChatterQuit_Thread = ExeThread(
                        self.classpath, odbcChatterQuitLog, "",
                        odbcChatterNameExe, self.odbcChatterQuit_params,
                        self.example_timeout)
                    cppChatterQuit_Thread = ExeThread(
                        self.classpath, cppChatterQuitLog, "",
                        cppChatterNameExe, self.cppChatterQuit_params,
                        self.example_timeout)

                    os.chdir(self.pPath)

                    self.startOSPL()

                    cppMsgBoard_Thread.start()
                    odbcMsgBoard_Thread.start()
                    time.sleep(5)
                    odbcChatter1_Thread.start()
                    odbcChatter2_Thread.start()
                    cppChatter1_Thread.start()
                    cppChatter2_Thread.start()

                    odbcChatter1_Thread.join(self.example_timeout)
                    odbcChatter2_Thread.join(self.example_timeout)
                    cppChatter1_Thread.join(self.example_timeout)
                    cppChatter2_Thread.join(self.example_timeout)

                    time.sleep(10)
                    odbcChatterQuit_Thread.start()
                    cppChatterQuit_Thread.start()

                    odbcChatterQuit_Thread.join(self.example_timeout)
                    cppChatterQuit_Thread.join(self.example_timeout)
                    cppMsgBoard_Thread.join(self.example_timeout)
                    odbcMsgBoard_Thread.join(self.example_timeout)

            except Exception as ex:
                msg = "Exception running ", str(ex)

            try:
                self.stopOSPL()
            except Exception as ex:
                print("Exception stopping OpenSplice ", str(ex))

            if msg == "NONE":
                try:
                    #Allow time for all messages to be written to log
                    time.sleep(15)
                    super(dbmsconnect, self).copyLogs()

                    if os.path.isfile(self.ospl_error_log):
                        msg = "ospl-error.log found"

                    print("checking odbcMsgBoardLog with odbcmsgboard_conds",
                          odbcMsgBoardLog, odbcmsgboard_conds)
                    self.checkResults(odbcMsgBoardLog, odbcmsgboard_conds)

                    print("checking odbcChatter1Log with odbcchatter_conds",
                          odbcChatter1Log, odbcchatter_conds)
                    self.checkResults(odbcChatter1Log, odbcchatter_conds)

                    print("checking odbcChatter2Log with odbcchatter_conds",
                          odbcChatter2Log, odbcchatter_conds)
                    self.checkResults(odbcChatter2Log, odbcchatter_conds)

                    self.checkResults(cppMsgBoardLog, cppmsgboard_conds)
                    self.checkResults(cppChatter1Log, cppchatter_conds)
                    self.checkResults(cppChatter2Log, cppchatter_conds)

                    self.checkOSPLInfoLog(self.ospl_info_log)
                except LogCheckFail as lf:
                    reason = str(lf)
                    if "OpenSpliceDDS Warnings" in reason:
                        msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                    else:
                        msg = "LogCheckFail: " + str(lf)
                except Exception:
                    msg = "Exception checking logs " + str(sys.exc_info()[0])

                logdir = os.path.join(os.environ['LOGDIR'], "examples",
                                      "run_" + os.environ['EXRUNTYPE'],
                                      self.exdir)
                dbmsconnLog = os.path.join(self.pPath, 'dbmsconnect.log')
                print("dbmsconnect.log is ", dbmsconnLog)
                copy(dbmsconnLog, logdir)

            if msg != "NONE":
                result = "FAIL"

            try:
                self.writeResult(result, self.exdir, "", msg)
            except Exception as ex:
                print("Exception writing result", str(ex))

            try:
                self.cleanUp()
            except Exception as ex:
                print("Exception cleaning  up", str(ex))

        except Exception as ex:
            print("Unexpected exception ", str(ex))
        finally:
            os.chdir(currPath)
Ejemplo n.º 9
0
    def runExample(self, lang, extra, types):
        if lang == "cs" and not self.host.isWindows():
            print "C# not supported on " + self.host.name
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:
                if extra == "all":
                    self.runExampleAllExtra(lang, extra, types)
                else:

                    print "In runExample for " + self.expath + ": " + self.name + ": " + lang + ":" + extra

                    currPath = os.getcwd()
                    try:
                        super(durability, self).setExampleResultDir(lang, extra)

                        exSfx = ""

                        if self.host.isWindows() and not "java" in lang:
                            exSfx = ".exe"

                        msg = "NONE"
                        result = "PASS"

                        os.putenv("OSPL_URI", self.uri)
                        os.environ["OSPL_URI"] = self.uri

                        try:
                            self.setLogPathAndLogs(lang, extra)

                            pub1Log = os.path.join(self.pPath, 'publisher1.log')
                            pub2Log = os.path.join(self.pPath, 'publisher2.log')
                            pub3Log = os.path.join(self.pPath, 'publisher3.log')

                            transSub1Log = os.path.join(self.pPath, 'trans_subscriber1.log')
                            transSub2Log = os.path.join(self.pPath, 'trans_subscriber2.log')
                            transSub3Log = os.path.join(self.pPath, 'trans_subscriber3.log')
                            persSub1Log = os.path.join(self.pPath, 'pers_subscriber1.log')
                            persSub2Log = os.path.join(self.pPath, 'pers_subscriber2.log')

                            try:
                                tmpDir = os.path.join(self.pPath, "tmp")
                                if os.path.isdir(tmpDir):
                                    shutil.rmtree (tmpDir)
                            except:
                                print "Failed to remove", tmpDir

                            with open ('examples.json') as data_file:
                                data = json.load(data_file)

                            pubName = data[self.expath][self.name]["executables"][lang]["pubName"]
                            subName = data[self.expath][self.name]["executables"][lang]["subName"]

                            sub_conds_file = data[self.expath][self.name]["log_conditions_file"][lang]["sub_conds"]
                            pub_conds_file = data[self.expath][self.name]["log_conditions_file"][lang]["pub_conds"]

                            sub_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', sub_conds_file)
                            pub_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'yaml', pub_conds_file)

                            if pubName != "":
                                if self.classpath == "":
                                    pubExe = os.path.join(self.pPath, pubName) + exSfx
                                    if not os.path.isfile (pubExe):
                                        msg = "MissingExecutable: " + pubExe
                                else:
                                    pubExe = pubName

                            if subName != "":
                                if self.classpath == "":
                                    subExe = os.path.join(self.pPath, subName) + exSfx
                                    if not os.path.isfile (subExe):
                                        msg = "MissingExecutable: " + subExe
                                else:
                                    pubExe = subName

                            if msg == "NONE":
                                transSub1_Thread = ExeThread(self.classpath,  transSub1Log, lang, subExe, self.transSub_params, self.example_timeout * 2)
                                transSub2_Thread = ExeThread(self.classpath,  transSub2Log, lang, subExe, self.transSub_params, self.example_timeout * 2)
                                transSub3_Thread = ExeThread(self.classpath,  transSub3Log, lang, subExe, self.transSub_params, self.example_timeout * 2)

                                persSub1_Thread = ExeThread(self.classpath, persSub1Log, lang, subExe, self.persSub_params, self.example_timeout * 2)
                                persSub2_Thread = ExeThread(self.classpath, persSub2Log, lang, subExe, self.persSub_params, self.example_timeout * 2)

                                pub1Thread = ExeThread(self.classpath, pub1Log, lang, pubExe, self.pub1_params, self.example_timeout * 2)
                                pub2Thread = ExeThread(self.classpath, pub2Log, lang, pubExe, self.pub2_params, self.example_timeout * 2)
                                pub3Thread = ExeThread(self.classpath, pub3Log, lang, pubExe, self.pub3_params, self.example_timeout * 2)
                                os.chdir(self.pPath)

                                self.startOSPL()

                                transSub1_Thread.start()
                                pub1Thread.start()

                                pub1Thread.join(self.example_timeout)
                                transSub1_Thread.join(self.example_timeout)

                                self.stopOSPL()

                                self.startOSPL()
                                transSub2_Thread.start()
                                pub2Thread.start()

                                time.sleep(2)
                                transSub3_Thread.start()

                                pub2Thread.join(self.example_timeout)
                                transSub2_Thread.join(self.example_timeout)
                                transSub3_Thread.join(self.example_timeout)

                                self.stopOSPL()

                                self.startOSPL()

                                persSub1_Thread.start()
                                pub3Thread.start()
                                pub3Thread.join(self.example_timeout)
                                persSub1_Thread.join(self.example_timeout)

                                self.stopOSPL()

                                self.startOSPL()

                                persSub2_Thread.start()
                                persSub2_Thread.join(self.example_timeout)

                        except Exception:
                            msg = "Exception running " + str(sys.exc_info()[0])

                        try:
                            self.stopOSPL()
                        except Exception as ex:
                            print "Exception stopping OpenSplice ", str(ex)

                        if msg == "NONE":
                            try:
                                time.sleep (5)
                                super(durability, self).copyLogs()

                                if os.path.isfile (self.ospl_error_log):
                                    msg = "ospl-error.log found"

                                # the java versions of the Durability example do not write anything
                                # to the publisher output log - so only check the publisher log if
                                # the language is not a java language
                                if not "java" in lang:
                                    self.checkResults(pub1Log, pub_conds)
                                    self.checkResults(pub2Log, pub_conds)
                                    self.checkResults(pub3Log, pub_conds)

                                self.checkResults(transSub1Log, sub_conds)
                                self.checkResults(transSub2Log, sub_conds)
                                self.checkResults(transSub3Log, sub_conds)
                                self.checkResults(persSub1Log, sub_conds)
                                self.checkResults(persSub2Log, sub_conds)

                                self.checkOSPLInfoLog(self.ospl_info_log)

                            except LogCheckFail as lf:
                                reason = str(lf)
                                if "OpenSpliceDDS Warnings" in reason:
                                    msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                                else:
                                    msg = "LogCheckFail: " + str(lf)
                            except Exception:
                                msg = "Exception checking logs " + str(sys.exc_info()[0])


                        if msg != "NONE":
                            result = "FAIL"

                        try:
                            self.writeResult (result,  self.expath + self.name, lang, msg)
                        except Exception as ex:
                            print "Exception writing result ", str(ex)

                        try:
                            self.cleanUp()
                        except Exception as ex:
                            print "Exception cleaning up ", str(ex)

                    except Exception as ex:
                        print "Unexpected exception", str(ex)
                    finally:
                        os.chdir(currPath)
Ejemplo n.º 10
0
    def runExample(self, lang, extra, types):
        if lang == "cs" and not self.host.isWindows():
            print "C# not supported on " + self.host.name
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:
                if extra == "all":
                    self.runExampleAllExtra(lang, extra, types)
                else:

                    print "In runExample for " + self.expath + ": " + self.name + ": " + lang + ":" + extra

                    currPath = os.getcwd()
                    try:
                        super(durability,
                              self).setExampleResultDir(lang, extra)

                        exSfx = ""

                        if self.host.isWindows() and not "java" in lang:
                            exSfx = ".exe"

                        msg = "NONE"
                        result = "PASS"

                        os.putenv("OSPL_URI", self.uri)
                        os.environ["OSPL_URI"] = self.uri

                        try:
                            self.setLogPathAndLogs(lang, extra)

                            pub1Log = os.path.join(self.pPath,
                                                   'publisher1.log')
                            pub2Log = os.path.join(self.pPath,
                                                   'publisher2.log')
                            pub3Log = os.path.join(self.pPath,
                                                   'publisher3.log')

                            transSub1Log = os.path.join(
                                self.pPath, 'trans_subscriber1.log')
                            transSub2Log = os.path.join(
                                self.pPath, 'trans_subscriber2.log')
                            transSub3Log = os.path.join(
                                self.pPath, 'trans_subscriber3.log')
                            persSub1Log = os.path.join(self.pPath,
                                                       'pers_subscriber1.log')
                            persSub2Log = os.path.join(self.pPath,
                                                       'pers_subscriber2.log')

                            try:
                                tmpDir = os.path.join(self.pPath, "tmp")
                                if os.path.isdir(tmpDir):
                                    shutil.rmtree(tmpDir)
                            except:
                                print "Failed to remove", tmpDir

                            with open('examples.json') as data_file:
                                data = json.load(data_file)

                            pubName = data[self.expath][
                                self.name]["executables"][lang]["pubName"]
                            subName = data[self.expath][
                                self.name]["executables"][lang]["subName"]

                            sub_conds_file = data[self.expath][self.name][
                                "log_conditions_file"][lang]["sub_conds"]
                            pub_conds_file = data[self.expath][self.name][
                                "log_conditions_file"][lang]["pub_conds"]

                            sub_conds = os.path.join(
                                os.path.dirname(os.path.realpath(__file__)),
                                'yaml', sub_conds_file)
                            pub_conds = os.path.join(
                                os.path.dirname(os.path.realpath(__file__)),
                                'yaml', pub_conds_file)

                            if pubName != "":
                                if self.classpath == "":
                                    pubExe = os.path.join(self.pPath,
                                                          pubName) + exSfx
                                    if not os.path.isfile(pubExe):
                                        msg = "MissingExecutable: " + pubExe
                                else:
                                    pubExe = pubName

                            if subName != "":
                                if self.classpath == "":
                                    subExe = os.path.join(self.pPath,
                                                          subName) + exSfx
                                    if not os.path.isfile(subExe):
                                        msg = "MissingExecutable: " + subExe
                                else:
                                    pubExe = subName

                            if msg == "NONE":
                                transSub1_Thread = ExeThread(
                                    self.classpath, transSub1Log, lang, subExe,
                                    self.transSub_params,
                                    self.example_timeout * 2)
                                transSub2_Thread = ExeThread(
                                    self.classpath, transSub2Log, lang, subExe,
                                    self.transSub_params,
                                    self.example_timeout * 2)
                                transSub3_Thread = ExeThread(
                                    self.classpath, transSub3Log, lang, subExe,
                                    self.transSub_params,
                                    self.example_timeout * 2)

                                persSub1_Thread = ExeThread(
                                    self.classpath, persSub1Log, lang, subExe,
                                    self.persSub_params,
                                    self.example_timeout * 2)
                                persSub2_Thread = ExeThread(
                                    self.classpath, persSub2Log, lang, subExe,
                                    self.persSub_params,
                                    self.example_timeout * 2)

                                pub1Thread = ExeThread(
                                    self.classpath, pub1Log, lang, pubExe,
                                    self.pub1_params, self.example_timeout * 2)
                                pub2Thread = ExeThread(
                                    self.classpath, pub2Log, lang, pubExe,
                                    self.pub2_params, self.example_timeout * 2)
                                pub3Thread = ExeThread(
                                    self.classpath, pub3Log, lang, pubExe,
                                    self.pub3_params, self.example_timeout * 2)
                                os.chdir(self.pPath)

                                self.startOSPL()

                                transSub1_Thread.start()
                                pub1Thread.start()

                                pub1Thread.join(self.example_timeout)
                                transSub1_Thread.join(self.example_timeout)

                                self.stopOSPL()

                                self.startOSPL()
                                transSub2_Thread.start()
                                pub2Thread.start()

                                time.sleep(2)
                                transSub3_Thread.start()

                                pub2Thread.join(self.example_timeout)
                                transSub2_Thread.join(self.example_timeout)
                                transSub3_Thread.join(self.example_timeout)

                                self.stopOSPL()

                                self.startOSPL()

                                persSub1_Thread.start()
                                pub3Thread.start()
                                pub3Thread.join(self.example_timeout)
                                persSub1_Thread.join(self.example_timeout)

                                self.stopOSPL()

                                self.startOSPL()

                                persSub2_Thread.start()
                                persSub2_Thread.join(self.example_timeout)

                        except Exception:
                            msg = "Exception running " + str(sys.exc_info()[0])

                        try:
                            self.stopOSPL()
                        except Exception as ex:
                            print "Exception stopping OpenSplice ", str(ex)

                        if msg == "NONE":
                            try:
                                time.sleep(5)
                                super(durability, self).copyLogs()

                                if os.path.isfile(self.ospl_error_log):
                                    msg = "ospl-error.log found"

                                # the java versions of the Durability example do not write anything
                                # to the publisher output log - so only check the publisher log if
                                # the language is not a java language
                                if not "java" in lang:
                                    self.checkResults(pub1Log, pub_conds)
                                    self.checkResults(pub2Log, pub_conds)
                                    self.checkResults(pub3Log, pub_conds)

                                self.checkResults(transSub1Log, sub_conds)
                                self.checkResults(transSub2Log, sub_conds)
                                self.checkResults(transSub3Log, sub_conds)
                                self.checkResults(persSub1Log, sub_conds)
                                self.checkResults(persSub2Log, sub_conds)

                                self.checkOSPLInfoLog(self.ospl_info_log)

                            except LogCheckFail as lf:
                                reason = str(lf)
                                if "OpenSpliceDDS Warnings" in reason:
                                    msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                                else:
                                    msg = "LogCheckFail: " + str(lf)
                            except Exception:
                                msg = "Exception checking logs " + str(
                                    sys.exc_info()[0])

                        if msg != "NONE":
                            result = "FAIL"

                        try:
                            self.writeResult(result, self.expath + self.name,
                                             lang, msg)
                        except Exception as ex:
                            print "Exception writing result ", str(ex)

                        try:
                            self.cleanUp()
                        except Exception as ex:
                            print "Exception cleaning up ", str(ex)

                    except Exception as ex:
                        print "Unexpected exception", str(ex)
                    finally:
                        os.chdir(currPath)
Ejemplo n.º 11
0
    def runExample(self, lang, extra, types):
        print("runExample ", lang, extra, types)
        if lang == "cs" and not self.host.isWindows():
            print("C# not supported on " + self.host.name)
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:
                if extra == "all":
                    self.runExampleAllExtra(lang, extra, types)
                else:
                    currPath = os.getcwd()

                    if lang == "cs":
                        ping_conds = os.path.join(
                            os.path.dirname(os.path.realpath(__file__)),
                            'yaml', 'ping_cs_conditions.yaml')
                    else:
                        ping_conds = os.path.join(
                            os.path.dirname(os.path.realpath(__file__)),
                            'yaml', 'ping_conditions.yaml')

                    pong_conds = os.path.join(
                        os.path.dirname(os.path.realpath(__file__)), 'yaml',
                        'pong_conds.yaml')

                    try:
                        super(pingpong, self).setExampleResultDir(lang, extra)

                        msg = "NONE"
                        result = "PASS"

                        exSfx = ""

                        isJava = False

                        if lang == "java" or lang == "java5":
                            isJava = True

                        if self.host.isWindows() and not isJava:
                            exSfx = ".exe"

                        try:
                            self.setLogPathAndLogs(lang, extra)

                            pingLog = os.path.join(self.pPath, 'ping.log')
                            pongLog = os.path.join(self.pPath, 'pong.log')

                            with open('examples.json') as data_file:
                                data = json.load(data_file)

                            os.chdir(self.pPath)

                            if extra == "corba" and isJava:
                                if lang == "java":
                                    runLang = "cj"
                                    corbaJar = "dcpscj.jar"
                                else:
                                    runLang = "cj5"
                                    corbaJar = "dcpscj5.jar"

                                ospljar = os.path.join(os.environ['OSPL_HOME'],
                                                       "jar", corbaJar)
                                classes = os.path.join(os.environ['OSPL_HOME'],
                                                       "examples", self.expath,
                                                       self.name, lang, extra,
                                                       "classes")
                                self.classpath = ospljar + os.pathsep + classes
                            else:
                                runLang = lang

                            print("runLang is ", runLang)

                            if extra == "corba":
                                exes = "corba_executables"
                            else:
                                exes = "executables"

                            pongName = data[self.expath][
                                self.name][exes][lang]["pubName"]
                            pingName = data[self.expath][
                                self.name][exes][lang]["subName"]

                            if pongName != "":
                                if self.classpath == "" and not isJava:
                                    pongExe = os.path.join(
                                        self.pPath, pongName) + exSfx
                                    if not os.path.isfile(pongExe):
                                        msg = "MissingExecutable: " + pongExe

                                else:
                                    pongExe = pongName

                            if pingName != "":
                                if self.classpath == "" and not isJava:
                                    pingExe = os.path.join(
                                        self.pPath, pingName) + exSfx
                                    if not os.path.isfile(pingExe):
                                        msg = "MissingExecutable: " + pingExe
                                else:
                                    pingExe = pingName

                            if msg == "NONE":
                                self.startOSPL()

                                print("Going to start pong thread")
                                pongThread = ExeThread(self.classpath, pongLog,
                                                       runLang, pongExe,
                                                       self.partitions,
                                                       self.pongTimeout)
                                pongThread.start()

                        except Exception as ex:
                            msg = "Failure running PingPong:  pong " + str(ex)

                        if msg == "NONE":
                            try:
                                if types == "all":
                                    runTypes = self.types
                                else:
                                    runTypes = types

                                for t in runTypes:
                                    print("Running ping with", t)

                                    pingArgs = [
                                        self.BLOCKSIZE, self.BLOCKCOUNT, t
                                    ]
                                    pingArgs.extend(self.partitions)
                                    pingThread = ExeThread(
                                        self.classpath, pingLog, runLang,
                                        pingExe, pingArgs, self.pingTimeout)
                                    pingThread.start()
                                    pingThread.join(self.pingTimeout)

                                    # Allow time for output to be written to log
                                    time.sleep(2)
                            except Exception as ex:
                                msg = "Failure running PingPong:  ping " + str(
                                    ex)

                        if msg == "NONE":
                            try:
                                pingQuitThread = ExeThread(
                                    self.classpath, pingLog, runLang, pingExe,
                                    self.pingQuitArgs, self.pingTimeout)
                                pingQuitThread.start()
                                pingQuitThread.join(self.pingTimeout)
                                pongThread.join(self.pongTimeout)
                            except:
                                msg = "Failure running PingPong: ping quit " + str(
                                    sys.exc_info()[0])

                        try:
                            self.stopOSPL()
                        except Exception as ex:
                            print("Exception stopping OpenSplice ", str(ex))

                        try:
                            self.copyLogs()

                            if os.path.isfile(self.ospl_error_log):
                                msg = "ospl-error.log found"

                            self.checkResults(pingLog, ping_conds)

                            self.checkResults(pongLog, pong_conds)

                            self.checkOSPLInfoLog(self.ospl_info_log)
                        except LogCheckFail as lf:
                            reason = str(lf)
                            if "Ignore excess messages" in reason:
                                msg = "LogCheckFail: \"Ignore excess messages\" in run.log"
                            elif "PING_min triggered, but no data available" in reason:
                                msg = "LogCheckFail: \"PING_min triggered\" in run.log"
                            elif "OpenSpliceDDS Warnings" in reason:
                                msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                            else:
                                msg = "LogCheckFail: " + str(lf)
                        except Exception as ex:
                            msg = "Exception: " + str(ex)

                        if msg != "NONE":
                            result = "FAIL"

                        resultLang = lang

                        if extra == "corba":
                            if lang == "cpp":
                                resultLang = "ccpp"
                            elif lang == "java":
                                resultLang = "cj"
                            elif lang == "java5":
                                resultLang = "cj5"

                        try:
                            print("WRiting result for ",
                                  self.name + " " + resultLang)
                            self.writeResult(result, self.expath + self.name,
                                             resultLang, msg)
                        except Exception as ex:
                            print("Exception writing result", str(ex))

                        try:
                            self.cleanUp()
                        except Exception as ex:
                            print("Exception cleaning up", str(ex))

                    except Exception as ex:
                        print("Unexpected exception", str(ex))
                    finally:
                        os.chdir(currPath)
Ejemplo n.º 12
0
    def runExample(self, lang, extra, types):
        print "runExample ", lang, extra, types
        if lang == "cs" and not self.host.isWindows():
            print "C# not supported on " + self.host.name
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:
                if extra == "all":
                    self.runExampleAllExtra(lang, extra, types)
                else:
                    currPath = os.getcwd()

                    ping_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)),  'yaml', 'ping_conditions.yaml')

                    pong_conds = os.path.join(os.path.dirname(os.path.realpath(__file__)),  'yaml', 'pong_conds.yaml')

                    try:
                        super(pingpong, self).setExampleResultDir(lang, extra)

                        msg = "NONE"
                        result = "PASS"

                        exSfx = ""

                        isJava = False

                        if lang == "java" or lang == "java5":
                            isJava = True

                        if self.host.isWindows() and not isJava:
                            exSfx = ".exe"

                        try:
                            self.setLogPathAndLogs(lang, extra)

                            pingLog = os.path.join(self.pPath, 'ping.log')
                            pongLog = os.path.join(self.pPath, 'pong.log')

                            with open ('examples.json') as data_file:
                                data = json.load(data_file)

                            os.chdir(self.pPath)

                            if extra == "corba" and isJava:
                                if lang == "java":
                                    runLang = "cj"
                                    corbaJar = "dcpscj.jar"

                                ospljar = os.path.join(os.environ['OSPL_HOME'], "jar", corbaJar)
                                classes = os.path.join(os.environ['OSPL_HOME'], "examples", self.expath, self.name, lang, extra, "classes")
                                self.classpath = ospljar + os.pathsep + classes
                            else:
                                runLang = lang

                            print "runLang is ", runLang

                            if extra == "corba":
                                exes = "corba_executables"
                                if lang == "java5":
                                    exes = "executables"
                            else:
                                exes = "executables"

                            pongName = data[self.expath][self.name][exes][lang]["pubName"]
                            pingName  = data[self.expath][self.name][exes][lang]["subName"]

                            if pongName != "":
                                if self.classpath == "" and not isJava:
                                    pongExe = os.path.join(self.pPath, pongName) + exSfx
                                    if not os.path.isfile (pongExe):
                                        msg = "MissingExecutable: " + pongExe

                                else:
                                    pongExe = pongName

                            if pingName != "":
                                if self.classpath == "" and not isJava:
                                    pingExe = os.path.join(self.pPath, pingName) + exSfx
                                    if not os.path.isfile (pingExe):
                                        msg = "MissingExecutable: " + pingExe
                                else:
                                    pingExe = pingName

                            if msg == "NONE":
                                self.startOSPL()

                                print "Going to start pong thread"
                                pongThread = ExeThread(self.classpath, pongLog, runLang, pongExe, self.partitions, self.pongTimeout)
                                pongThread.start()

                        except Exception as ex:
                            msg = "Failure running PingPong:  pong " + str(ex)

                        if msg == "NONE":
                            try:
                                if types == "all":
                                    runTypes = self.types
                                else:
                                    runTypes = types

                                for t in runTypes:
                                    print "Running ping with", t

                                    pingArgs = [self.BLOCKSIZE, self.BLOCKCOUNT, t]
                                    pingArgs.extend(self.partitions)
                                    pingThread = ExeThread(self.classpath, pingLog, runLang, pingExe, pingArgs, self.pingTimeout)
                                    pingThread.start()
                                    pingThread.join(self.pingTimeout)

                                    # Allow time for output to be written to log
                                    time.sleep(5)
                            except Exception as ex:
                                msg = "Failure running PingPong:  ping " + str(ex)

                        if msg == "NONE":
                            try:
                                pingQuitThread = ExeThread(self.classpath, pingLog, runLang, pingExe, self.pingQuitArgs, self.pingTimeout)
                                pingQuitThread.start()
                                pingQuitThread.join(self.pingTimeout)
                                pongThread.join(self.pongTimeout)
                            except:
                                msg = "Failure running PingPong: ping quit " + str(sys.exc_info()[0])

                        try:
                            self.stopOSPL()
                        except Exception as ex:
                            print "Exception stopping OpenSplice ", str(ex)

                        try:
                            self.copyLogs()

                            if os.path.isfile (self.ospl_error_log):
                                msg = "ospl-error.log found"

                            self.checkResults(pingLog, ping_conds)

                            self.blockCheck (pingLog)

                            self.checkResults(pongLog, pong_conds)

                            self.checkOSPLInfoLog(self.ospl_info_log)
                        except LogCheckFail as lf:
                            reason = str(lf)
                            if "Ignore excess messages" in reason:
                                msg = "LogCheckFail: \"Ignore excess messages\" in run.log"
                            elif "PING_min triggered, but no data available" in reason:
                                msg = "LogCheckFail: \"PING_min triggered\" in run.log"
                            elif "OpenSpliceDDS Warnings" in reason:
                                msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                            else:
                                msg = "LogCheckFail: " + str (lf)
                        except Exception as ex:
                            msg = "Exception: " + str (ex)

                        if msg != "NONE":
                            result = "FAIL"

                        resultLang = lang

                        if extra == "corba":
                            if lang == "cpp":
                                resultLang = "ccpp"
                            elif lang == "java":
                                resultLang = "cj"

                        try:
                            print "WRiting result for ", self.name + " " + resultLang
                            self.writeResult (result, self.expath +  self.name, resultLang, msg)
                        except Exception as ex:
                            print "Exception writing result", str(ex)

                        try:
                            self.cleanUp()
                        except Exception as ex:
                            print "Exception cleaning up", str(ex)

                    except Exception as ex:
                        print "Unexpected exception", str(ex)
                    finally:
                        os.chdir(currPath)
Ejemplo n.º 13
0
    def runExample(self, lang, extra, types):
        if lang == "cs" and not self.host.isWindows():
            print "C# not supported on " + self.host.name
        else:
            if lang == "all":
                self.runExampleAll(extra)
            else:
                currPath = os.getcwd()

                try:
                    self.setExampleResultDir(lang, extra)

                    with open('examples.json') as data_file:
                        data = json.load(data_file)

                    pubName = data[self.expath][
                        self.name]["executables"][lang]["pubName"]
                    pubParams = data[self.expath][
                        self.name]["params"]["pub_params"]
                    subName = data[self.expath][
                        self.name]["executables"][lang]["subName"]
                    subParams = data[self.expath][
                        self.name]["params"]["sub_params"]
                    sub2Name = data[self.expath][
                        self.name]["executables"][lang]["sub2Name"]
                    sub2Params = data[self.expath][
                        self.name]["params"]["sub2_params"]

                    exSfx = ""

                    if self.host.isWindows() and not "java" in lang:
                        exSfx = ".exe"

                    msg = "NONE"
                    result = "PASS"

                    try:
                        super(rmihelloworld,
                              self).setLogPathAndLogs(lang, extra)

                        pub1Log = os.path.join(self.pPath, 'publisher1.log')
                        pub2Log = os.path.join(self.pPath, 'publisher2.log')
                        sub1Log = os.path.join(self.pPath, 'subscriber1.log')
                        sub2Log = os.path.join(self.pPath, 'subscriber2.log')

                        sub_conds_file = data[self.expath][self.name][
                            "log_conditions_file"][lang]["sub_conds"]
                        pub_conds_file = data[self.expath][self.name][
                            "log_conditions_file"][lang]["pub_conds"]

                        sub_conds = os.path.join(
                            os.path.dirname(os.path.realpath(__file__)),
                            'yaml', sub_conds_file)
                        pub_conds = os.path.join(
                            os.path.dirname(os.path.realpath(__file__)),
                            'yaml', pub_conds_file)

                        os.chdir(self.pPath)

                        if self.classpath == "":
                            pubexe = os.path.join(self.pPath, pubName) + exSfx
                            if not os.path.isfile(pubexe):
                                msg = "MissingExecutable: " + pubexe
                        else:
                            pubexe = pubName

                        pubThread = ExeThread(self.classpath, pub1Log, lang,
                                              pubexe, "", self.example_timeout)
                        pub2Thread = ExeThread(self.classpath, pub2Log, lang,
                                               pubexe, "",
                                               self.example_timeout)

                        if self.classpath == "":
                            subexe = os.path.join(self.pPath, subName) + exSfx
                            if not os.path.isfile(subexe):
                                msg = "MissingExecutable: " + subexe

                            sub2exe = os.path.join(self.pPath,
                                                   sub2Name) + exSfx
                            if not os.path.isfile(sub2exe):
                                msg = "MissingExecutable: " + sub2exe
                        else:
                            subexe = subName
                            sub2exe = sub2Name

                        subThread = ExeThread(self.classpath, sub1Log, lang,
                                              subexe, "", self.example_timeout)
                        sub2Thread = ExeThread(self.classpath, sub2Log, lang,
                                               sub2exe, "",
                                               self.example_timeout)

                        self.startOSPL()

                        pubThread.start()
                        time.sleep(1)
                        subThread.start()
                        pubThread.join(self.example_timeout)
                        subThread.join(self.example_timeout)

                        pub2Thread.start()
                        time.sleep(1)
                        sub2Thread.start()
                        pub2Thread.join(self.example_timeout)
                        sub2Thread.join(self.example_timeout)

                    except Exception:
                        msg = "Exception running " + str(sys.exc_info()[0])

                    try:
                        self.stopOSPL()
                    except Exception as ex:
                        print "Exception stopping OpenSplice ", str(ex)

                    if msg == "NONE":
                        try:
                            super(rmihelloworld, self).copyLogs()

                            if os.path.isfile(self.ospl_error_log):
                                msg = "ospl-error.log found"

                            #self.checkResults(sub1Log, sub_conds)
                            #self.checkResults(sub2Log, sub_conds)
                            #self.checkResults(pub1Log, pub_conds)
                            #self.checkResults(pub2Log, pub_conds)

                            self.checkOSPLInfoLog(self.ospl_info_log)

                        except LogCheckFail as lf:
                            if "OpenSpliceDDS Warnings" in reason:
                                msg = "LogCheckFail: OpenSpliceDDS Warnings in ospl-info.log"
                            else:
                                msg = "LogCheckFail: " + str(lf)
                        except Exception:
                            msg = "Exception checking logs " + str(
                                sys.exc_info()[0])

                    if msg != "NONE":
                        result = "FAIL"

                    try:
                        self.writeResult(result, self.expath + self.name, lang,
                                         msg)
                    except Exception as ex:
                        print "Exception writing result", str(ex)

                    try:
                        self.cleanUp()
                    except Exception as ex:
                        print "Exception cleaning up", str(ex)

                except Exception as ex:
                    print "Unexpected exception", str(ex)
                finally:
                    os.chdir(currPath)