0

I am trying this Vector CANoe knowledge base article. I want to call a function from a Python module from inside a CAPL test module. But before that I want to run a simple Python script and capture console output of its execution.

Using sysExec and TestWaitForSyscall CAPL APIs I am able to execute the Python script. The test case also passes but I am not able to capture console output on Write window (basically "Hello World"). The APIs are only able to check the exit codes but I also want to be able to capture the console output as well.

Here is the example CAPL code that executes the Python script as a separate program and gets the result in form of exit code.

void MainTest ()
{
  CTC_CallPyScript();
}

testcase CTC_CallPyScript()
{
  long res;
  char absPath[256];
  
  getAbsFilePath("", absPath, elcount(absPath));
  write(absPath);
  res=testWaitForSyscall(absPath, "py HelloWorld.py", 0, 5000);
  if(res==1)
    testStepPass("Pass.");
  else
    testStepFail("Fail.");

}

I tried outputting into a text file like so but I don't see any file getting generated. Also I want to avoid this approach since file I/O is costly when making such calls frequently.

  res=testWaitForSyscall(absPath, "py HelloWorld.py > output.txt", 0, 5000);

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.