Help needed in redirecting eclipse console output to Linux terminal

64 views
Skip to first unread message

Sandeep Torvi

unread,
Jan 12, 2021, 2:19:32 AM1/12/21
to cpputest
Hello all,

Regarding CppUTest test results, I want to redirect eclipse console output to linux terminal. 
How can i do that ?

For example : 

TEST(CTestSuite, test6) - 0 ms
TEST(CTestSuite, test5) - 0 ms
TEST(CTestSuite, test4) - 0 ms
TEST(CTestSuite, test3) - 0 ms
TEST(CTestSuite, test2) - 0 ms
TEST(CTestSuite, test1) - 0 ms

OK (6 tests, 6 ran, 9 checks, 0 ignored, 0 filtered out, 1 ms)

When the test is executed, above output is displayed on eclipse console, but i want to redirect this to linux terminal..

Is it possible ?

Any help would be appreciated ... 

Thank you.
Sandeep

Ryan Hartlage

unread,
Jan 12, 2021, 1:30:31 PM1/12/21
to cpputest
Why don't you run the tests from a Linux terminal? Is there a reason you need to run them from Eclipse?

Ryan

--
You received this message because you are subscribed to the Google Groups "cpputest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpputest+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cpputest/83692e1e-81bc-47e6-bd26-8775943e5236n%40googlegroups.com.

Sandeep Torvi

unread,
Jan 13, 2021, 12:34:32 AM1/13/21
to cpputest
Thanks Ryan, the reason why i am running from Eclipse is .. my complete SW framework is configured in eclipse and hence the Cpputest also pretty much integrated with the workspace. 
CommandLineTestRunner::RunAllTests(argc, argv)  is part of my service which gets whenever service is launched from the framework. So now the issue is when i run debug command from terminal, the output of cpputest results is displayed on eclipse console, which i would interested to display on same linux terminal where i run debug command.

So i was thinking if we can override the below class from cpputest source and redirect the output from eclipse console to linux terminal 

class ConsoleTestOutput: public TestOutput
{
public:
    explicit ConsoleTestOutput()
    {
    }
    virtual ~ConsoleTestOutput()
    {
    }

    virtual void printBuffer(const char* s) _override;
    virtual void flush() _override;

private:
    ConsoleTestOutput(const ConsoleTestOutput&);
    ConsoleTestOutput& operator=(const ConsoleTestOutput&);
};

Request to help in resolving this issue. 

Thanks
Sandeep Torvi

Ryan Hartlage

unread,
Jan 13, 2021, 5:49:10 AM1/13/21
to cpputest
Hey Sandeep,

The Eclipse console is basically an integrated Linux terminal. CppUTest just writes to stdout/stderr which the host console/terminal displays. If you want to be able to run something in Eclipse but have its output be redirected to a standalone terminal, you will need to do leverage an Eclipse feature or use an IPC mechanism to pipe the output elsewhere from within CppUTest.

I'm having trouble understanding what your setup looks like, but I'm guessing that you start the test executable from within Eclipse and attach a debugger from a terminal. If so, why not have the debugger launch the test executable? Alternately, why not debug from within Eclipse?

Ryan


James Grenning

unread,
Jan 15, 2021, 12:27:56 PM1/15/21
to cpputest

Sandeep

Eclipse creates a command line executable. You should be able to go to the command line and run the exe file after building in eclipse.

I think Ryan is steering you the same direction.

Cheers, James


James Grenning -- Author of TDD for Embedded C - wingman-sw.com/tddec
Join my live-via-the-web TDD Training
wingman software
wingman-sw.com -- blog -- @jwgrenning -- facebook

--

Sandeep Torvi

unread,
Jan 15, 2021, 1:07:55 PM1/15/21
to cppu...@googlegroups.com
Thanks James, yeah i got the point about executable and passing command line switches like -c / -v / -ojunit etc... 

But the catch here is I am not running "CommandLineTestRunner::RunAllTests(ac, av)" in specific main() function but instead its being called from a service or process when launched. 
So i won't generate a command line executable but will generate a static library which i will link to service executable. 

Now,  when I launch RunAllTests(ac, av) from service from linux terminal using some service debug commands, i get tests' output  to eclipse instead of linux terminal.. 

Best Regards,
Sandeep

You received this message because you are subscribed to a topic in the Google Groups "cpputest" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cpputest/urzFL5Dkx5M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cpputest+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cpputest/B6A26956-3243-4912-8C78-30455CD09B75%40grenning.net.
Reply all
Reply to author
Forward
0 new messages