From 505c965e3655b8ae94880a23baf8ecc2092163c4 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 26 Sep 2017 15:24:58 +0200 Subject: CTRL: add unit tests for CTRL command parsing 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 --- tests/ctrl/ctrl_test.ok | 102 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'tests/ctrl/ctrl_test.ok') diff --git a/tests/ctrl/ctrl_test.ok b/tests/ctrl/ctrl_test.ok index 8f97a27f..9c8877b2 100644 --- a/tests/ctrl/ctrl_test.ok +++ b/tests/ctrl/ctrl_test.ok @@ -7,3 +7,105 @@ ctrl type 4 is SET_REPLY -> 4 OK ctrl type 5 is TRAP -> 5 OK ctrl type 6 is ERROR -> 6 OK ctrl type 64 is unknown 0x40 [PARSE FAILED] +test parsing: 'GET 1 variable' +id = '1' +variable = 'variable' +value = NULL +reply = NULL +ok +test parsing: 'GET 1 variable\n' +id = '1' +variable = 'variable\n' +value = NULL +reply = NULL +ok +test parsing: 'GET 1 var\ni\nable' +id = '1' +variable = 'var\ni\nable' +value = NULL +reply = NULL +ok +test parsing: 'GET 1 variable value' +id = '1' +variable = 'variable' +value = NULL +reply = NULL +ok +test parsing: 'GET 1 variable value\n' +id = '1' +variable = 'variable' +value = NULL +reply = NULL +ok +test parsing: 'GET 1 variable multiple value tokens' +id = '1' +variable = 'variable' +value = NULL +reply = NULL +ok +test parsing: 'GET 1 variable multiple value tokens\n' +id = '1' +variable = 'variable' +value = NULL +reply = NULL +ok +test parsing: 'SET 1 variable value' +id = '1' +variable = 'variable' +value = 'value' +reply = NULL +ok +test parsing: 'SET 1 variable value\n' +id = '1' +variable = 'variable' +value = 'value' +reply = NULL +ok +test parsing: 'SET weird_id variable value' +id = 'weird_id' +variable = 'variable' +value = 'value' +reply = NULL +ok +test parsing: 'SET weird_id variable value\n' +id = 'weird_id' +variable = 'variable' +value = 'value' +reply = NULL +ok +test parsing: 'SET 1 variable multiple value tokens' +id = '1' +variable = 'variable' +value = 'multiple value tokens' +reply = NULL +ok +test parsing: 'SET 1 variable multiple value tokens\n' +id = '1' +variable = 'variable' +value = 'multiple value tokens' +reply = NULL +ok +test parsing: 'SET 1 variable value_with_trailing_spaces ' +id = '1' +variable = 'variable' +value = 'value_with_trailing_spaces ' +reply = NULL +ok +test parsing: 'SET 1 variable value_with_trailing_spaces \n' +id = '1' +variable = 'variable' +value = 'value_with_trailing_spaces ' +reply = NULL +ok +test parsing: 'SET \n special_char_id value' +id = '\n' +variable = 'special_char_id' +value = 'value' +reply = NULL +ok +test parsing: 'SET \t special_char_id value' +id = '\t' +variable = 'special_char_id' +value = 'value' +reply = NULL +ok -- cgit v1.2.3