chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes

Hello,

i am currently checking if isolator++ would be capable to test some parts of our legacy code. I came across a function which has 15 arguments and i am having trouble to test this.

I created a small example which is reproducing the issue, at least in my setup

#include <gtest/gtest.h>
#include <Isolator.h>
#include <iostream>

class ExampleTest : public ::testing::Test {
 public:
    virtual void TearDown() {
        ISOLATOR_CLEANUP();
    }
};

namespace NS1 {
    int calctest(int &i1, bool &b1, int &i2, bool &b2, bool &b3, bool &b4);
    int calctest2(int &i1, bool &b1, int &i2, bool &b2, bool &b3, bool &b4, bool &b5);
}

int NS1::calctest(int &i1, bool &b1, int &i2, bool &b2, bool &b3, bool &b4) {
    return 1;
}
int NS1::calctest2(int &i1, bool &b1, int &i2, bool &b2, bool &b3, bool &b4, bool &b5) {
    return 1;
}

static int fakedCalctest(int &i1, bool &b1, int &i2, bool &b2, bool &b3, bool &b4) {
    std::cout << "&i1:" << &i1 << " &i2:" << &i2 << " &b1:" << &b1 << " &b2:" << &b2 << " &b3:" << &b3 << " &b4:" << &b4
              << std::endl;
    return 2;
}
static int fakedCalctest2(int &i1, bool &b1, int &i2, bool &b2, bool &b3, bool &b4, bool &b5) {
    std::cout << "&i1:" << &i1 << " &i2:" << &i2 << " &b1:" << &b1 << " &b2:" << &b2 << " &b3:" << &b3 << " &b4:" << &b4
              << " &b5:" << &b5 << std::endl;
    return 2;
}

class calcClass {
 private:
    int doAction(int aid, int &apl);
};

int calcClass::doAction(int aid, int &apl) {
    int  res = 0, i1 = -1, i2 = -1;
    bool b1 = false, b2 = false, b3 = false, b4 = false, b5 = false;

    std::cout << "&i1:" << &i1 << " &i2:" << &i2 << " &b1:" << &b1 << " &b2:" << &b2 << " &b3:" << &b3 << " &b4:" << &b4
              << " &b5:" << &b5 << std::endl;

    // res = NS1::calctest(i1, b1, i2, b2, b3, b4);  // this works fine
    res = NS1::calctest2(i1, b1, i2, b2, b3, b4, b5);  // this is making problems
    return res;
}

TEST_F(ExampleTest, FirstTest) {
    WHEN_CALLED(NS1::calctest(ANY_REF(int), ANY_REF(bool), ANY_REF(int), ANY_REF(bool), ANY_REF(bool), ANY_REF(bool)))
        .DoStaticOrGlobalInstead(fakedCalctest, NULL);
    WHEN_CALLED(NS1::calctest2(ANY_REF(int), ANY_REF(bool), ANY_REF(int), ANY_REF(bool), ANY_REF(bool), ANY_REF(bool), ANY_REF(bool)))
        .DoStaticOrGlobalInstead(fakedCalctest2, NULL);

    int        retVar = -999, aid = 0, apl = 1;
    calcClass *mcalcClass = new calcClass();

    ISOLATOR_INVOKE_FUNCTION(retVar, mcalcClass, doAction, aid, &apl);
    EXPECT_EQ(retVar, 2);
}

 

the two outputs are delivering:
&i1:0x7ffce37e1cdc &i2:0x7ffce37e1ce0 &b1:0x7ffce37e1cd7 &b2:0x7ffce37e1cd8 &b3:0x7ffce37e1cd9 &b4:0x7ffce37e1cda &b5:0x7ffce37e1cdb

&i1:0x7ffce37e1cdc &i2:0x7ffce37e1ce0 &b1:0x7ffce37e1cd7 &b2:0x7ffce37e1cd8 &b3:0x7ffce37e1cd9 &b4:0x7ffce37e1cda &b5:0x7ffce37e1a00

for me it seems like there is a wrong address for b5 delivered to fakedCalctest2 which is making problems if you want to manipulate this value.

Is it possible that this problem only appears when the amount of arguments is higher than 6? Because the fakedCalctest with 6 and less arguments are working like intendent and fakedCalctest2 with 7 (or 15) arguments not. Or am i doing something wrong?

Thank you very much!

asked by EJ (600 points)

Hi EJ,

We've tried to reproduce the issue on our machine with the example you provided, but on our machine the result is ok.

I mean, the 2 address of the b5 argument are equal in the output window.

Can you please share in addition to the Architecture of your machine the version of Isolator++?

Cheers,

Alon Sapozhnikov.

Hello,

the tests are built and running in a docker container FROM ubuntu:16.04.

gcc version is 5.4.0, google test framework 1.8.1 and

according to the test output i am using *** Typemock Isolator++ Professional 4.1.2.20 (64bit) ***

do you need anything else?

Thank you for your help!

Hi EJ,

Thank you for the input.

I was able to reproduce your issue.
I will dig into it and keep you posted.

Cheers,

Alon Sapozhnikov.

Hi EJ,

We found the issue.

Unfortunately, the fix will take time.
I will keep you posted as soon as I have an update.

Cheers,

Alon Sapozhnikov. 

1 Answer

0 votes

Hi EJ,

Thank you for contacting us, and thank you for the detailed information.
The issue in not known to us, we are checking it.

Can you please share with us the architecture of your machine? (e.g: windows? 64bit? etc...)

Cheers,

Alon Sapozhnikov.
Support Specilaist.


 

answered by Alon_TypeMock (5k points)
...