Merge lp://qastaging/~awe/phablet-extras/ofono-unittest-gprs-context into lp://qastaging/phablet-extras/ofono
- ofono-unittest-gprs-context
- Merge into ofono
Status: | Merged |
---|---|
Approved by: | Ricardo Salveti |
Approved revision: | 67 |
Merged at revision: | 48 |
Proposed branch: | lp://qastaging/~awe/phablet-extras/ofono-unittest-gprs-context |
Merge into: | lp://qastaging/phablet-extras/ofono |
Diff against target: |
2756 lines (+1901/-394) 20 files modified
Makefile.am (+23/-2) drivers/rilmodem/gprs-context.c (+187/-260) drivers/rilmodem/rilutil.c (+2/-81) drivers/rilmodem/rilutil.h (+0/-13) gril/gril.c (+19/-6) gril/gril.h (+10/-8) gril/grilreply.c (+225/-0) gril/grilreply.h (+57/-0) gril/grilrequest.c (+213/-0) gril/grilrequest.h (+63/-0) gril/grilunsol.c (+158/-0) gril/grilunsol.h (+62/-0) gril/grilutil.c (+47/-0) gril/grilutil.h (+9/-5) gril/parcel.c (+15/-19) gril/ril_constants.h (+12/-0) include/types.h (+10/-0) unit/test-grilreply.c (+339/-0) unit/test-grilrequest.c (+312/-0) unit/test-grilunsol.c (+138/-0) |
To merge this branch: | bzr merge lp://qastaging/~awe/phablet-extras/ofono-unittest-gprs-context |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Salveti (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Sergio Schvezov | Needs Fixing | ||
Review via email:
|
Commit message
[gril/rilmodem] Re-factor gprs-context code to facilitate unit testing.
Description of the change
This branch re-factors rilmodem's gprs-context module such that all RIL message code has been moved into the lower gril base layer. This was done to allow unit testing of the RIL parcel code used by gprs-context.
Once this code has been merged, the plan is to re-factor the rest of the rilmodem code using this approach.
Tested on an un-flipped raring image running on maguro.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
Build failure is due to the fact that I didn't add the unit test source file... I'm working on restoring it, and should have this branch updated by end-of-day.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:56
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sergio Schvezov (sergiusens) wrote : | # |
I would split:
823 +static void test_invalid_
834 + /* Test invalid radio tech values */
847 + /* Test invalid data profile */
855 + /* Invalid APNs */
...
and so on for the other test functions into individual test cases.
Also consider the posibility of a test fixture for each of these test functions(at your discretion)
https:/
Is it a good idea to make a free_reply (or with similar name) that would take care of freeing the complete struct and then just call that?
238 + g_strfreev(
239 + g_strfreev(
240 + g_strfreev(
249 + g_free(
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
@Sergio
Thanks for the comments, and I agree that splitting the tests out probably makes sense.
Also per our discussion yesterday, I will split grilmessages.c into three separate files: grilrequests.c, grilreplies.c, and grilevents.c.
Finally, I also mentioned that I only added unit tests for the SETUP_DATA_CALL request. I will go ahead and add unit tests for the corresponding reply as well.
I should be able to wrap up all these changes today.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sergio Schvezov (sergiusens) wrote : | # |
On Fri, Jul 12, 2013 at 12:15 PM, Tony Espy <email address hidden> wrote:
> @Sergio
>
> Thanks for the comments, and I agree that splitting the tests out probably makes sense.
>
> Also per our discussion yesterday, I will split grilmessages.c into three separate files: grilrequests.c, grilreplies.c, and grilevents.c.
>
> Finally, I also mentioned that I only added unit tests for the SETUP_DATA_CALL request. I will go ahead and add unit tests for the corresponding reply as well.
>
> I should be able to wrap up all these changes today.
Sounds good to me :-)
- 57. By Tony Espy
-
[gril/rilmodem] Split grilmessages into grilrequest, grilreply, and grilunsol.
- 58. By Tony Espy
-
[rilmodem] Back out AudioSystem and Makefile.am changes made by mistake.
- 59. By Tony Espy
-
[gril] Re-factored low-level message support into type-specific modules.
- 60. By Tony Espy
-
[gril] Fixed the tracing logic, and cleaned up some minor warnings.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:60
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:61
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
Two last things need to be fixed.
First, the CI build fails due to a unit test failure. This is the test I mentioned earlier that was also failing in pbuild.
ERROR:unit/
Test test tries to compare wire-format parcel data ( stored in rilp.data ) to a static guchar of bytes that represent what the parcel wire format should look like.
The second issue is how the gprs-context code handles setup_data_call failures. I'm not sure if a failure callback triggers a disconnect from the core ofono code or not. If it does, then the code should be fine as is. If it doesn't, then this could potentially leave an active data call within RIL, and thus we should explicitly disconnect in this case.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
OK, so it appears the failure callback doesn't trigger a disconnect, so I'll modify the code to do that if the SETUP_DATA_CALL reply triggers a message validation error.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
I'll plan on landing the final bits over the weekend...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:62
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
OK, both problems are now fixed.
Data calls are properly disconnected if a reply is received from RIL that is deemed invalid by the gril code.
The unit test failure was due to a subtle bug in parcel_w_string() which could result in invalid string terminator bytes to be included due to an incorrect offset used to write the terminating utf16 0x00000.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:63
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:64
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ricardo Salveti (rsalveti) wrote : | # |
127 - if (message->req != RIL_UNSOL_
128 - ofono_error(
129 - message->req);
130 - return;
131 - }
Why did you remove the above? g_ril_unsol_
1017 + g_free(reply);
1611 + g_free(call);
1621 + g_free(unsol);
Not an issue, but as you're checking for call and unsol just before free, you could include the g_free call as part of the if scope.
901 +#define OFONO_EINVAL(error) do { \
902 + error->type = OFONO_ERROR_
903 + error->error = -EINVAL; \
904 +} while (0)
905 +
906 +#define OFONO_NO_
907 + error->type = OFONO_ERROR_
908 + error->error = 0; \
909 +} while (0)
910 +
These would be better if defined somewhere in a common ofono code, not just for ril.
2018 +static const struct ril_msg reply_data_
2019 + .buf = (gchar *) &reply_
2052 +static const struct ril_msg reply_data_
2053 + .buf = (gchar *) &reply_
2084 +static const struct ril_msg reply_data_
2085 + .buf = (gchar *) &reply_
2115 +static const struct ril_msg reply_data_
2116 + .buf = (gchar *) &reply_
2147 +static const struct ril_msg reply_data_
2148 + .buf = (gchar *) &reply_
2176 +static const struct ril_msg reply_data_
2177 + .buf = (gchar *) &reply_
Would you mind changing the test id to match the same number used by both structs? Otherwise it gets quite confusing when reading the code, as data_call_invalid_2 is part of invalid_parcel_1, instead of invalid_parcel_2 (which is a natural reading by our brain).
Other than those minor comments, code looks good (although it could technically be separated in more MRs, as we discussed).
Will now test in both mako and maguro.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ricardo Salveti (rsalveti) wrote : | # |
Tested with both mako and maguro and it seems to be all good :-)
Just minor issue I got with my maguro is that the modem can't attach anymore it seems, but don't think it's related with this MR (might be that intermittent issue we had this week).
Will test a bit more with maguro...
Would be nice if you could double check with it as well.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ricardo Salveti (rsalveti) wrote : | # |
Yeah, can't get my mako to attach anymore, with/without NM, and even after a clean install.
We might be having another issue somewhere in this code, which is not related with this MR.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ricardo Salveti (rsalveti) wrote : | # |
Argh, *maguro*.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ricardo Salveti (rsalveti) wrote : | # |
Ok, the issue with maguro is that it cannot attach at first, but it works after restarting ofono =\
First run, not attached:
http://
Second run, attached:
http://
Wonder if this is a side effect of that roaming bug you fixed (will follow up this in a bug).
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
Question, were you testing with just this MR, or the combined MRs? As we discussed, the attach fix was split between the two MRs due to the heavy re-factoring of gprs-context.c in this MR.
I will look at your comments above, which all seem reasonable and try and update the MR later today.
I will also do some more testing to see if I can reproduce any of the issues you ran into while testing.
Note, my fix assumes that NetworkManager always sets the ConnectionManager's 'Powered' on start-up. Perhaps there's a race condition and this isn't always happening?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ricardo Salveti (rsalveti) wrote : | # |
Just with this MR, and without NetworkManager involved. Was just tracking the ofono state after it was properly initialized.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
OK, I'll plan on giving both a shake-down tomorrow after I clean up the couple of things based on your previous comment.
This code really shouldn't have effected whether GPRS attaches or not, as it only touches the gprs-context driver.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tony Espy (awe) wrote : | # |
> 127 - if (message->req != RIL_UNSOL_
> 128 - ofono_error(
> 129 - message->req);
> 130 - return;
> 131 - }
>
> Why did you remove the above? g_ril_unsol_
> checking if the message is indeed UNSOL_DATA_
I removed it because it wasn't needed. If you look at the code in gril.c that handles unsolicited messages, it's not really possible for the wrong message to be passed to a registered listener, as that's the whole purpose of registering for a particular message.
> 1017 + g_free(reply);
> 1611 + g_free(call);
> 1621 + g_free(unsol);
>
> Not an issue, but as you're checking for call and unsol just before free, you
> could include the g_free call as part of the if scope.
Done.
> 901 +#define OFONO_EINVAL(error) do { \
> 902 + error->type = OFONO_ERROR_
> 903 + error->error = -EINVAL; \
> 904 +} while (0)
> 905 +
> 906 +#define OFONO_NO_
> 907 + error->type = OFONO_ERROR_
> 908 + error->error = 0; \
> 909 +} while (0)
> 910 +
>
> These would be better if defined somewhere in a common ofono code, not just
> for ril.
Done, moved these to <ofono/type.h>.
>
> 2018 +static const struct ril_msg reply_data_
> 2019 + .buf = (gchar *) &reply_
>
> 2052 +static const struct ril_msg reply_data_
> 2053 + .buf = (gchar *) &reply_
>
> 2084 +static const struct ril_msg reply_data_
> 2085 + .buf = (gchar *) &reply_
>
> 2115 +static const struct ril_msg reply_data_
> 2116 + .buf = (gchar *) &reply_
>
> 2147 +static const struct ril_msg reply_data_
> 2148 + .buf = (gchar *) &reply_
>
> 2176 +static const struct ril_msg reply_data_
> 2177 + .buf = (gchar *) &reply_
>
> Would you mind changing the test id to match the same number used by both
> structs? Otherwise it gets quite confusing when reading the code, as
> data_call_invalid_2 is part of invalid_parcel_1, instead of invalid_parcel_2
> (which is a natural reading by our brain).
Yea, I thought about this an since the first test case didn't actually have parcel_data, I thought it would be weird having the first parcel data variable start with "2". Oh well, not a big deal. Re-number per your suggestion.
> Other than those minor comments, code looks good (although it could
> technically be separated in more MRs, as we discussed).
>
> Will now test in both mako and maguro.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:67
http://
Executed test runs:
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ricardo Salveti (rsalveti) wrote : | # |
Good, thanks!
FAILED: Continuous integration, rev:53 jenkins. qa.ubuntu. com/job/ phablet- extras- ofono-ci/ 51/ jenkins. qa.ubuntu. com/job/ phablet- extras- ofono-saucy- armhf-ci/ 26/console
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ phablet- extras- ofono-ci/ 51/rebuild
http://