Commit Graph

11 Commits

Author SHA1 Message Date
JingPiao Chen
7b20432b32 tests: extend TEST_NESTED_NLATTR_OBJECT macro
Extend TEST_NESTED_NLATTR_OBJECT macro for multi-nested netlink
attributes, such as

	[MDBA_MDB] = {
		[MDBA_MDB_ENTRY] = {
			[MDBA_MDB_ENTRY_INFO] {
				struct br_mdb_entry
				[MDBA_MDB_EATTR attributes]
			}
		}
	}

* tests/test_nlattr.h (TEST_NESTED_NLATTR_OBJECT_EX_,
TEST_NESTED_NLATTR_OBJECT_EX): New macros.
(TEST_NESTED_NLATTR_OBJECT): Use TEST_NESTED_NLATTR_OBJECT_EX_.
2017-09-17 12:04:11 +00:00
JingPiao Chen
16f073a05d tests: check decoding of TCA_STAB netlink attribute of tcmsg
* tests/test_nlattr.h (TEST_NESTED_NLATTR_ARRAY): New macro.
* tests/nlattr_tca_stab.c: New file.
* tests/gen_tests.in (nlattr_tca_stab): New entry.
* tests/pure_executables.list: Add nlattr_tca_stab.
* tests/.gitignore: Likewise.
2017-09-07 11:35:04 +00:00
JingPiao Chen
bf1a463c79 tests: check decoding of IFLA_PROTINFO netlink attribute of ifinfomsg
* tests/nlattr_ifla_brport.c: New file.
* tests/gen_tests.in (nlattr_ifla_brport): New entry.
* tests/pure_executables.list: Add nlattr_ifla_brport.
* tests/.gitignore: Likewise.
* tests/test_nlattr.h (TEST_NESTED_NLATTR_OBJECT): New macro.
2017-09-01 08:41:08 +00:00
a10961a9e1 tests/test_nlattr.h: include <stdint.h>
* tests/test_nlattr.h: Include <stdint.h> for definition of uint16_t
used by init_nlattr.
2017-08-15 22:34:46 +00:00
JingPiao Chen
3acb11230c tests: extend TEST_NLATTR_OBJECT macro
* tests/test_nlattr.h (TEST_NLATTR_OBJECT_EX_,
TEST_NLATTR_OBJECT_EX): New macros.
(TEST_NLATTR_OBJECT): Use TEST_NLATTR_OBJECT_EX_.
2017-07-24 11:18:43 +00:00
JingPiao Chen
fd817962f9 tests: fix TEST_NLATTR_OBJECT and TEST_NLATTR_ARRAY for large objects
commit v4.17-161-gdbd0605 that adjusted TEST_NLATTR_OBJECT and
TEST_NLATTR_ARRAY for large objects, only changed the pattern
print length, large length still can be specified as nla_data_len,
resulting to output mismatch.

* tests/test_nlattr.h (TEST_NLATTR_OBJECT): Pass "plen"
both as nla_data_len and slen arguments of TEST_NLATTR_
in len < sizeof(object) case.
(TEST_NLATTR_ARRAY): Likewise, Pass "plen" both as nla_data_len
and slen arguments of TEST_NLATTR_ in len < sizeof(object[0]) case.
2017-07-09 00:14:20 +00:00
JingPiao Chen
3d30063836 tests: introduce TEST_NLATTR_nla macro in test_nlattr.h
Explicitly make struct nlattr * pointer which is internal
to TEST_NLATTR_ macro available to its varadic arguments.

* tests/test_nlattr.h (TEST_NLATTR_): Rename nla to TEST_NLATTR_nla.
2017-07-09 00:06:29 +00:00
JingPiao Chen
73698eb8f1 netlink: print unrecognized attribute data in hex
* nlattr.c (decode_nlattr_with_data): Replace printstrn
with printstr_ex and set QUOTE_FORCE_HEX flag.
* tests/tests.h (print_quoted_hex): New prototype.
* tests/print_quoted_string.c (print_quoted_hex): New function.
* tests/test_nlattr.h (TEST_NLATTR_OBJECT, TEST_NLATTR_ARRAY): Use it
for updated expected output.  Change the type of "plen" variable
to unsigned int.
* tests/nlattr.c (test_nlattr): Update expected output.
2017-07-07 16:43:41 +00:00
dbd060526c tests: adjust TEST_NLATTR_OBJECT and TEST_NLATTR_ARRAY for large objects
* tests/test_nlattr.h (TEST_NLATTR_OBJECT, TEST_NLATTR_ARRAY): Add
support for objects larger than DEFAULT_STRLEN.
* tests/nlattr_inet_diag_msg.c (main): Change pattern size
from DEFAULT_STRLEN to 4096.
* tests/nlattr_netlink_diag_msg.c: Likewise.
* tests/nlattr_unix_diag_msg.c: Likewise.

Reported-by: JingPiao Chen <chenjingpiao@gmail.com>
2017-07-03 15:14:54 +00:00
26954f7753 Unify different generic PRINT_FIELD_* implementations
Create a new header print_fields.h and move generic PRINT_FIELD_*
macros there.

* print_fields.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* netlink_sock_diag.c: Include "print_fields.h".
(PRINT_FIELD_U, PRINT_FIELD_X, PRINT_FIELD_COOKIE, PRINT_FIELD_FLAGS,
PRINT_FIELD_XVAL): Move to print_fields.h file.
* quota.c: Include "print_fields.h".
(PRINT_FIELD_D): Move to print_fields.h file.
(PRINT_FIELD_U, PRINT_FIELD_X): Remove.
* statx.c: Include "print_fields.h".
(PRINT_FIELD_U): Remove.
(SYS_FUNC(statx)): Update PRINT_FIELD_U callers.
* tests/quotactl.h: Include "print_fields.h".
* tests/quotactl-xfs.c: Update callers of PRINT_FIELD_* macros.
* tests/quotactl.c: Likewise.
(PRINT_FIELD_D, PRINT_FIELD_U, PRINT_FIELD_X): Remove.
* tests/test_nlattr.h: Include "print_fields.h".
(PRINT_FIELD_U, PRINT_FIELD_X): Remove.
* tests/xstatx.c: Include "print_fields.h".
(PRINT_FIELD_U): Remove.
(print_stat): Update PRINT_FIELD_U callers.
* tests/tests.h [!STRACE_PRINTF] (STRACE_PRINTF): Define to printf.
2017-07-01 13:14:49 +00:00
aecff115c0 tests: enhance nlattr_inet_diag_msg test
* tests/test_nlattr.h: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/nlattr_inet_diag_msg.c: Include "test_nlattr.h".
(test_inet_diag_meminfo, test_inet_diag_vegasinfo,
test_inet_diag_dctcpinfo, test_inet_diag_bbrinfo): Remove.
(address): New variable.
(init_inet_diag_msg): Remove "address" argument, add const qualifier
to all remaining arguments.
(print_inet_diag_msg, print_uint): New functions.
(main): Use macros from test_nlattr.h file.
2017-06-30 21:38:49 +00:00