Topic
6 replies Latest Post - ‏2013-04-18T16:35:16Z by WCWA_Massimiliano_D'Angelo
WCWA_Massimiliano_D'Angelo
19 Posts
ACCEPTED ANSWER

Pinned topic WriteTestExecutionLogFile

‏2013-04-16T08:03:02Z |

Has anyone got the WriteTestExecutionLogFile to work? No log file is generated in C:\tmp .

My goal is to save on files the messages shown on stdout on the command window during the execution of a test case.

 

Thanks,

Massimiliano

 

  • chr_btc-es
    chr_btc-es
    67 Posts
    ACCEPTED ANSWER

    Re: WriteTestExecutionLogFile

    ‏2013-04-17T15:52:11Z  in response to WCWA_Massimiliano_D'Angelo

    Hi,

    this log file will not contain messages from stdout. TestConductor logs information about notifications from the (animated) application and commands sent to the application in this file. This file is intended for analyzing cases where events, operations or behavioral steps happend in the application but seems to be not seen by TestConductor.

    This is relevant mainly when executing SD based tests in animation based testing mode as these tests rely on notifications from the animation layer. When creating a TestArchitecture, per default assertion based testing mode is used: The WriteTestExecutionLogFile property doesn't have any effect in this mode.

     

    If you want to create such a log file: Invoke Rhapsody menu Tools->Test Conductor. In the dialog, set TestingMode to 'AnimationBased', this sets the mode to be used for newly created TestArchitectures. Then create a new TestArchitecture, create an SD based TestCase and set the property on this TestCase before executing it.

     

    If you want to write your own log messages into a file: You should have a look at 'Test Actions' in the TC user guide; in Test Actions, you can enter additional code and add your messages to files etc. Test Actions are available for assertion based testing mode (SD based tests).

     

    Regards, Christian.

    • WCWA_Massimiliano_D'Angelo
      19 Posts
      ACCEPTED ANSWER

      Re: WriteTestExecutionLogFile

      ‏2013-04-17T17:36:05Z  in response to chr_btc-es

      Hi Christian,

      thanks for clarifying the issue with WriteTestExecutionLogFile.

      About the usage of TestActions, I am actually using them. Inside them I have printf statements (as in my model). Is it possible to redirect these printf to a file (without changing them to fprintf) ? I am looking for something like ./<executable> > mylogfile.txt , but I don't know how to tell Rhapsody to redirect the standard output of the executable to a file. Any ideas?

      Massimiliano

       

      • pathfinder_hartmut
        pathfinder_hartmut
        49 Posts
        ACCEPTED ANSWER

        Re: WriteTestExecutionLogFile

        ‏2013-04-18T09:43:25Z  in response to WCWA_Massimiliano_D'Angelo

        Hi,

        you could try to reopen stdout via freopen() in the initial-code segment of the configuration main file.

        Regards, Hartmut

        • WCWA_Massimiliano_D'Angelo
          19 Posts
          ACCEPTED ANSWER

          Re: WriteTestExecutionLogFile

          ‏2013-04-18T11:46:36Z  in response to pathfinder_hartmut

          Hi Hartmut,

          thanks for your reply. Apparently, this solution does not work. 

          Printouts are no more shown on the console, the file is created, but the file is empty. I have also tried to set line buffering (using setbuf), and to close the file (fclose) at the end of the execution.

          Honestly, I do not understand where printouts are redirected. I have got the same behaviour when trying to redirect to standard output adding "> myfile.txt" at the end of rtc_testexecution_script_content (tags in the configuration of the test component), which looks like

          "$executable" -resultfile "$rtc_resultfile" -logfile "$rtc_logfile" -tcontext $tcontext -tcase $tcase > myfile.txt .

           

          • pathfinder_hartmut
            pathfinder_hartmut
            49 Posts
            ACCEPTED ANSWER

            Re: WriteTestExecutionLogFile

            ‏2013-04-18T12:02:05Z  in response to WCWA_Massimiliano_D'Angelo

            Hi,

            strange. I tried and it worked for me. Please, find attached a simple Rhap801 Project.

            I just modified tag rtc_testexecution_script_content.

            And it seems to be important to fflush(stdout) after printing.

            After executing the TestCase in the model, you will find a 'banana.txt' file in the cg-directory containing the output, except for 'TestCase finished'

             

            Regards, Hartmut

            Attachments

            • WCWA_Massimiliano_D'Angelo
              19 Posts
              ACCEPTED ANSWER

              Re: WriteTestExecutionLogFile

              ‏2013-04-18T16:35:16Z  in response to pathfinder_hartmut

              Hi Hartmut, 

              you are actually right. Instead of using fflush, I was using fclose at the end of the execution, but I have realized it was never invoked. 

              I have solved the issue placing the freopen in the state startTestCase_state of the state machine of the scheduler of the test cases, whereas the fopen is called in the state startPostTestCaseOp_state . It works now. Moreover, doing this operation in this state machine makes easy to change the file name for each test case.

               

              Thanks all for your help!