summaryrefslogtreecommitdiffstats
path: root/tests/ctrl/ctrl_test.c
Commit message (Collapse)AuthorAgeFilesLines
* ctrl: tighten CTRL input parsingNeels Hofmeyr2017-12-201-64/+46
| | | | | | | | | | | | | | | | Validate that incoming CTRL commands... - have decimal IDs, - return error on trailing characters, - have invalid characters in variable identifiers, - send detailed error messages as reply to the requestor. Adjust ctrl_test.{c,ok}, which best show the change in behavior. Message handling causes log messages on stderr; previously, stderr was empty. Add '[ignore]' in testsuite.at so that the nonempty stderr doesn't cause test failures. Change-Id: I96a9b6b6a3a5e0b80513aa9eaa727ae8c9c7d7a1
* ctrl: on parse errors, return a detailed message to senderNeels Hofmeyr2017-12-181-1/+1
| | | | | | | | | | | The recently added ctrl_cmd_parse2() returns non-NULL cmd with error messages upon parsing errors. In handle_control_read(), use ctrl_cmd_parse2() and send those back to the CTRL command sender as reply. Retain the previous "Command parser error" reply only in case ctrl_cmd_parse2() should return NULL, which shouldn't actually happen at all. Change-Id: Ie35a02555b76913bb12734a76fc40fde7ffb244d
* ctrl_test: add two more current parsing bugs to prep for fixNeels Hofmeyr2017-12-181-0/+16
| | | | Change-Id: Id11bc326be2f0bc2746a928354e416495a18baf7
* ctrl: fix mem leak when handling GET_REPLY and SET_REPLYNeels Hofmeyr2017-12-181-3/+2
| | | | | | | | | | | | In ctrl_handle_msg() (code recently propagated from handle_control_read()), talloc_free() the parsed ctrl_cmd in all code paths. In particular, a free was missing in case ctrl_cmd_handle() returns CTRL_CMD_HANDLED. CTRL_CMD_HANDLED is triggered by GET_REPLY / SET_REPLY parsing, as show by ctrl_test.c. With the memleak fixed, adjust expected test output and make a detected mem leak abort the test immediately. Change-Id: Id583b413f8b8bd16e5cf92a8a9e8663903646381
* ctrl_test: show memleak when receiving GET_REPLY and SET_REPLY commandsNeels Hofmeyr2017-12-181-2/+22
| | | | | | | The "memleak!" output shows messages that lack a talloc_free() of the parsed ctrl command buffer. The leak shall be fixed in a subsequent patch. Change-Id: I2c3e4d08b769b9cd77593362ea36a28d681cd042
* ctrl_test: expand to test message handling and detect mem leaksNeels Hofmeyr2017-12-181-40/+129
| | | | | | | Subsequent patches that tighten CTRL input validation will make the results more interesting. Change-Id: Idd4cc7d193db1a7d761f72ed33ed46eea450a78f
* ctrl_test.c: replace print_escaped() with new osmo_escape_str()Neels Hofmeyr2017-12-181-36/+4
| | | | Change-Id: I12d3828dcc925f97fde11c360f1d60f3bd8cad8b
* CTRL: add unit tests for CTRL command parsingNeels Hofmeyr2017-09-271-0/+251
| | | | | | | | This uncovers some interesting behavior of the CTRL interface which we may want to guard against in subsequent patches: trailing whitespace, ignored tokens, special characters as cmd->id. Change-Id: If7af06d50ca71fd528b08cd70310774d5a53f0f7
* ctrl_test.c: fix build with GCC 7.1.1Vadim Yanitskiy2017-06-131-1/+1
| | | | | | | | | | | | | | | | According to GCC's online docs: When an inline function is not static, then the compiler must assume that there may be calls from other source files; since a global symbol can be defined only once in any program, the function must not be defined in the other source files, so the calls therein cannot be integrated. Therefore, a non-static inline function is always compiled on its own in the usual fashion. There is no any (performance or size) benefit from 'inline' keyword in this particular file, so let's replace one by 'static'. Change-Id: I11e1f1cfea09c6f0cf8225239e782b551d3eb52f
* Use value_string for ctrl_typeMax2017-03-011-0/+36
Use value_string for enum ctrl_type instead of custom code. Add corresponding unit tests. Related: OS#1615 Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28