1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #6529 from miri64/od/enh/reduce-func

od: simplify od module to only provide od_hex_dump
This commit is contained in:
Martine Lenders 2017-03-29 00:10:41 +02:00 committed by GitHub
commit f2c9d0c810
6 changed files with 50 additions and 891 deletions

View File

@ -350,6 +350,10 @@ ifneq (,$(filter gnrc_pktdump,$(USEMODULE)))
USEMODULE += od
endif
ifneq (,$(filter od,$(USEMODULE)))
USEMODULE += fmt
endif
ifneq (,$(filter newlib_nano,$(USEMODULE)))
USEMODULE += newlib
endif

View File

@ -9,15 +9,8 @@
/**
* @defgroup sys_od Object dump
* @ingroup sys
* @brief Allows to print out data dumps of memory regions in a similar fashion
* to the UNIX's
* <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/od.html">
* od
* </a> tool
* @brief Allows to print out data dumps of memory regions
*
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/od.html">
* od(1)
* </a>
* @{
*
* @file
@ -31,132 +24,24 @@
extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
/**
* @brief Bit-mask to extract address offset format settings from flags
*/
#define OD_FLAGS_ADDRESS_MASK (0xc000)
/**
* @brief Bit-mask to extract byte format settings from flags
*/
#define OD_FLAGS_BYTES_MASK (0x3e00)
/**
* @brief Bit-mask to extract length information for byte format from flags
*/
#define OD_FLAGS_LENGTH_MASK (0x00f7)
/**
* @anchor od_flags_address
* @name Address offset format flags
* @brief Flags to define format of the address offset
* @{
*/
#define OD_FLAGS_ADDRESS_OCTAL (0x0000) /**< octal address offset */
#define OD_FLAGS_ADDRESS_HEX (0x4000) /**< hexadecimal address offset */
#define OD_FLAGS_ADDRESS_DECIMAL (0x8000) /**< decimal address offset */
#define OD_FLAGS_ADDRESS_NONE (0xc000) /**< no address offset */
/** @} */
/**
* @anchor od_flags_bytes
* @name Bytes format flags
* @brief Flags to define format of the byte output
* @{
*/
/**
* @brief Print `LENGTH` bytes as `LENGTH`-wide octal integer (`LENGTH` is defined
* in the lower significant byte of the flags)
*/
#define OD_FLAGS_BYTES_OCTAL (0x0000)
/**
* @brief Print bytes as their represented character in ASCII
*/
#define OD_FLAGS_BYTES_CHAR (0x2000)
/**
* @brief Print `LENGTH` bytes as `LENGTH`-wide decimal integer (`LENGTH` is
* defined in the lower significant byte of the flags)
*/
#define OD_FLAGS_BYTES_INT (0x1000)
/**
* @brief Alias for @ref OD_FLAGS_BYTES_INT
*/
#define OD_FLAGS_BYTES_DECIMAL (OD_FLAGS_BYTES_INT)
/* XXX: No float support for now, but reserved 0x0800 for this */
/**
* @brief Print `LENGTH` bytes as `LENGTH`-wide decimal unsigned integer
* (`LENGTH` is defined in the lower significant byte of the flags)
*/
#define OD_FLAGS_BYTES_UINT (0x0400)
/**
* @brief Print `LENGTH` bytes as `LENGTH`-wide hexadecimal integer
* (`LENGTH` is defined in the lower significant byte of the flags)
*/
#define OD_FLAGS_BYTES_HEX (0x0200)
/** @} */
/**
* @anchor od_flags_length
* @name Bytes format length flags
* @brief Flags to define format length of the byte output
* @{
*/
#define OD_FLAGS_LENGTH_1 (0x0010) /**< 1 byte */
#define OD_FLAGS_LENGTH_2 (0x0020) /**< 2 byte */
#define OD_FLAGS_LENGTH_4 (0x0000) /**< 4 byte and default */
/**
* @brief 8 byte
*
* @warning not working with newlib-nano
*/
#define OD_FLAGS_LENGTH_8 (0x0080)
#define OD_FLAGS_LENGTH_CHAR (OD_FLAGS_LENGTH_1) /**< alias for OD_FLAGS_LENGTH_1 */
#define OD_FLAGS_LENGTH_SHORT (0x0002) /**< sizeof(short) byte */
#define OD_FLAGS_LENGTH_LONG (0x0004) /**< sizeof(long) byte */
/** @} */
/**
* @brief Default value for parameter *width* of @ref od()
* @brief Default value for parameter *width* of @ref od_hex_dump()
*/
#define OD_WIDTH_DEFAULT (16)
/**
* @brief Dumps memory stored at *data* up to *data_len* in octal, decimal, or
* hexadecimal representation to stdout
*
* @param[in] data Data to dump.
* @param[in] data_len Length in bytes of *data* to output.
* @param[in] width Number of bytes per line. If *width* is 0,
* @ref OD_WIDTH_DEFAULT is assumed as a default value.
* @param[in] flags Flags as defined in @ref od_flags_address and
* @ref od_flags_bytes
*/
void od(const void *data, size_t data_len, uint8_t width, uint16_t flags);
/**
* @brief Dumps memory stored at *data* up to *data_len* in octal, decimal, or
* @brief Dumps memory stored at *data* byte-wise up to *data_len* in
* hexadecimal representation to stdout with
* `flags == OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1`.
*
* @param[in] data Data to dump.
* @param[in] data_len Length in bytes of *data* to output.
* @param[in] width Number of bytes per line. If *width* is 0,
* @ref OD_WIDTH_DEFAULT is assumed as a default value.
*/
static inline void od_hex_dump(const void *data, size_t data_len, uint8_t width)
{
od(data, data_len, width, OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1);
}
void od_hex_dump(const void *data, size_t data_len, uint8_t width);
#ifdef __cplusplus
}

View File

@ -310,8 +310,7 @@ static inline void _print_chunk(void *chunk, size_t size, int num)
{
printf("=========== chunk %3d (%-10p size: %4u) ===========\n", num, chunk,
(unsigned int)size);
od(chunk, size, OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1);
od_hex_dump(chunk, size, OD_WIDTH_DEFAULT);
}
static inline void _print_unused(_unused_t *ptr)

View File

@ -11,371 +11,31 @@
*
* @file
*/
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <stdint.h>
#include "fmt.h"
#include "od.h"
#define _OCTAL_BYTE_LENGTH (3)
#define _INT_BYTE_LENGTH (3)
#define _HEX_BYTE_LENGTH (2)
static inline void _address_format(char *format, uint16_t flags)
void od_hex_dump(const void *data, size_t data_len, uint8_t width)
{
switch (flags & OD_FLAGS_ADDRESS_MASK) {
case OD_FLAGS_ADDRESS_OCTAL:
strncpy(format, "%09o", sizeof("%09o"));
break;
case OD_FLAGS_ADDRESS_HEX:
strncpy(format, "%06x", sizeof("%06x"));
break;
case OD_FLAGS_ADDRESS_DECIMAL:
strncpy(format, "%07d", sizeof("%07d"));
break;
default:
break;
}
}
static inline uint8_t _length(uint16_t flags)
{
if (flags & OD_FLAGS_BYTES_CHAR) {
return 1;
}
switch (flags & OD_FLAGS_LENGTH_MASK) {
case OD_FLAGS_LENGTH_1:
return 1;
case OD_FLAGS_LENGTH_SHORT:
return sizeof(short);
case OD_FLAGS_LENGTH_2:
return 2;
case OD_FLAGS_LENGTH_LONG:
return sizeof(long);
case OD_FLAGS_LENGTH_8:
return 8;
case OD_FLAGS_LENGTH_4:
default:
return 4;
}
}
static inline void _bytes_format(char *format, uint16_t flags)
{
if (flags & OD_FLAGS_BYTES_CHAR) {
strncpy(format, " %c", sizeof(" %c"));
return;
}
switch (flags & (OD_FLAGS_BYTES_MASK | OD_FLAGS_LENGTH_MASK)) {
case OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1:
strncpy(format, " %03o", sizeof(" %03o"));
break;
case OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2:
strncpy(format, " %06" PRIo16, sizeof(" %06" PRIo16));
break;
case OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_4:
strncpy(format, " %012" PRIo32, sizeof(" %012" PRIo32));
break;
case OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_8:
strncpy(format, " %024" PRIo64, sizeof(" %024" PRIo64));
break;
#if !defined(__MACH__) && !defined(__mips__)
case OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_SHORT:
sprintf(format, " %%0%do", sizeof(short) * _OCTAL_BYTE_LENGTH);
break;
case OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_LONG:
sprintf(format, " %%0%dlo", sizeof(long) * _OCTAL_BYTE_LENGTH);
break;
#else /* !defined(__MACH__) && !defined(__mips__) */
case OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_SHORT:
sprintf(format, " %lu", sizeof(short) * _OCTAL_BYTE_LENGTH);
break;
case OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_LONG:
sprintf(format, " %lu", sizeof(long) * _OCTAL_BYTE_LENGTH);
break;
#endif /* !defined(__MACH__) && !defined(__mips__) */
case OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_1:
strncpy(format, " %4d", sizeof(" %4d"));
break;
case OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_2:
strncpy(format, " %6" PRId16, sizeof(" %6" PRId16));
break;
case OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_4:
strncpy(format, " %12" PRId32, sizeof(" %12" PRId32));
break;
case OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_8:
strncpy(format, " %24" PRId64, sizeof(" %24" PRId64));
break;
#if !defined(__MACH__) && !defined(__mips__)
case OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_SHORT:
sprintf(format, " %%%dd", sizeof(short) * _INT_BYTE_LENGTH);
break;
case OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_LONG:
sprintf(format, " %%%dld", sizeof(long) * _INT_BYTE_LENGTH);
break;
#else /* !defined(__MACH__) && !defined(__mips__) */
case OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_SHORT:
sprintf(format, " %%%ld", sizeof(short) * _INT_BYTE_LENGTH);
break;
case OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_LONG:
sprintf(format, " %%%ld", sizeof(long) * _INT_BYTE_LENGTH);
break;
#endif /* !defined(__MACH__) && !defined(__mips__) */
case OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_1:
strncpy(format, " %3u", sizeof(" %3u"));
break;
case OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_2:
strncpy(format, " %6" PRIu16, sizeof(" %6" PRIu16));
break;
case OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_4:
strncpy(format, " %12" PRIu32, sizeof(" %12" PRIu32));
break;
case OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_8:
strncpy(format, " %24" PRIu64, sizeof(" %24" PRIu64));
break;
#if !defined(__MACH__) && !defined(__mips__)
case OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_SHORT:
sprintf(format, " %%%uu", (unsigned)sizeof(short) * _INT_BYTE_LENGTH);
break;
case OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_LONG:
sprintf(format, " %%%ulu", sizeof(long) * _INT_BYTE_LENGTH);
break;
#else /* !defined(__MACH__) && !defined(__mips__) */
case OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_SHORT:
sprintf(format, " %%%lu", sizeof(short) * _INT_BYTE_LENGTH);
break;
case OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_LONG:
sprintf(format, " %%%lu", sizeof(long) * _INT_BYTE_LENGTH);
break;
#endif /* !defined(__MACH__) && !defined(__mips__) */
case OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1:
strncpy(format, " %02x", sizeof(" %02x"));
break;
case OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_2:
strncpy(format, " %04" PRIx16, sizeof(" %04" PRIx16));
break;
case OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_4:
strncpy(format, " %08" PRIx32, sizeof(" %08" PRIx32));
break;
case OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_8:
strncpy(format, " %016" PRIx64, sizeof(" %016" PRIx64));
break;
#if !defined(__MACH__) && !defined(__mips__)
case OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_SHORT:
sprintf(format, " %%0%ux", (unsigned)sizeof(short) * _HEX_BYTE_LENGTH);
break;
case OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_LONG:
sprintf(format, " %%0%ulx", (unsigned)sizeof(long) * _HEX_BYTE_LENGTH);
break;
#else /* !defined(__MACH__) && !defined(__mips__) */
case OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_SHORT:
sprintf(format, " %%0%lx", sizeof(short) * _HEX_BYTE_LENGTH);
break;
case OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_LONG:
sprintf(format, " %%0%lx", sizeof(long) * _HEX_BYTE_LENGTH);
break;
#endif /* !defined(__MACH__) && !defined(__mips__) */
default:
break;
}
}
static void _print_date(const void *data, size_t offset, char *format, uint8_t length,
uint16_t flags)
{
switch (length) {
case 1:
if (flags & OD_FLAGS_BYTES_CHAR) {
switch (((signed char *)data)[offset]) {
case '\0':
printf(" \\0");
return;
case '\a':
printf(" \\a");
return;
case '\b':
printf(" \\b");
return;
case '\f':
printf(" \\f");
return;
case '\n':
printf(" \\n");
return;
case '\r':
printf(" \\r");
return;
case '\t':
printf(" \\t");
return;
case '\v':
printf(" \\v");
return;
default:
if (((signed char *)data)[offset] < 0) {
printf(" %03o", ((unsigned char *)data)[offset]);
return;
}
else if (((signed char *)data)[offset] < 32) {
printf(" %03o", ((char *)data)[offset]);
return;
}
break;
}
}
if (flags & OD_FLAGS_BYTES_INT) {
printf(format, ((int8_t *)data)[offset]);
}
else {
printf(format, ((uint8_t *)data)[offset]);
}
break;
case 2:
if (flags & OD_FLAGS_BYTES_INT) {
printf(format, ((int16_t *)data)[offset]);
}
else {
printf(format, ((uint16_t *)data)[offset]);
}
break;
case 4:
default:
if (flags & OD_FLAGS_BYTES_INT) {
printf(format, ((int32_t *)data)[offset]);
}
else {
printf(format, ((uint32_t *)data)[offset]);
}
break;
case 8:
#ifndef MODULE_NEWLIB
if (flags & OD_FLAGS_BYTES_INT) {
printf(format, ((int64_t *)data)[offset]);
}
else {
printf(format, ((uint64_t *)data)[offset]);
}
#else
printf("%s", format);
#endif
break;
}
}
static int _log10(uint8_t a)
{
int res = 0;
while (a > 0) {
a /= 10;
++res;
}
return ++res;
}
void od(const void *data, size_t data_len, uint8_t width, uint16_t flags)
{
char address_format[5];
uint8_t date_length = _length(flags);
char bytes_format[_log10(date_length) + 7];
if (data_len == 0) {
return;
}
_address_format(address_format, flags);
_bytes_format(bytes_format, flags);
print_str("00000000");
if (width == 0) {
width = OD_WIDTH_DEFAULT;
}
if (width < date_length) {
width = 1;
}
else {
width = (width / date_length);
}
if (data_len % date_length) {
data_len = (data_len / date_length) + 1;
}
else {
data_len = data_len / date_length;
}
if ((flags & OD_FLAGS_ADDRESS_MASK) != OD_FLAGS_ADDRESS_NONE) {
printf(address_format, 0);
}
for (size_t i = 0; i < data_len; i++) {
_print_date(data, i, bytes_format, date_length, flags);
for (unsigned int i = 0; i < data_len; i++) {
print_str(" ");
print_byte_hex(((uint8_t *)data)[i]);
if ((((i + 1) % width) == 0) || i == (data_len - 1)) {
printf("\n");
puts("");
if (i != (data_len - 1)) {
if ((flags & OD_FLAGS_ADDRESS_MASK) != OD_FLAGS_ADDRESS_NONE) {
printf(address_format, date_length * (i + 1));
}
print_u32_hex((uint32_t)(i + 1));
}
}
}

View File

@ -30,159 +30,13 @@ static const char long_str[] = "\xff,a\xff.bcdefghijklmnop";
int main(void)
{
/* test data width vs. output width discrepency */
CALL(od(short_str, sizeof(short_str), OD_WIDTH_DEFAULT, 0));
CALL(od_hex_dump(short_str, sizeof(short_str), OD_WIDTH_DEFAULT));
/* Test different output width in default configuration*/
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, 0));
CALL(od(long_str, sizeof(long_str), 4, 0));
CALL(od(long_str, sizeof(long_str), 3, 0));
CALL(od(long_str, sizeof(long_str), 8, 0));
/* Test different address formats in default configuration */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_OCTAL));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_HEX));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_DECIMAL));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_NONE));
/* Test octal data format with different address formats */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_OCTAL));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_OCTAL | OD_FLAGS_BYTES_OCTAL));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_OCTAL));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_DECIMAL | OD_FLAGS_BYTES_OCTAL));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_ADDRESS_NONE | OD_FLAGS_BYTES_OCTAL));
/* Test different data formats */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_CHAR));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_DECIMAL));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_UINT));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX));
/* Test octal byte-wise output with different output lengths */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1));
CALL(od(long_str, sizeof(long_str), 4,
OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1));
CALL(od(long_str, sizeof(long_str), 3,
OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1));
CALL(od(long_str, sizeof(long_str), 8,
OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1));
/* Test different data formats with byte-wise output */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_CHAR | OD_FLAGS_LENGTH_1));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_1));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_1));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_1));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1));
/* Test octal 2-byte-wise output with different output lengths */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2));
CALL(od(long_str, sizeof(long_str), 4,
OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2));
CALL(od(long_str, sizeof(long_str), 3,
OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2));
CALL(od(long_str, sizeof(long_str), 8,
OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2));
/* Test 2-byte-char output (should just return normal char output) */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_CHAR | OD_FLAGS_LENGTH_2));
/* Test 2-byte-int output with different output widths */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_2));
CALL(od(long_str, sizeof(long_str), 5,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_2));
/* Test 2-byte-decimal output with different output widths */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_2));
CALL(od(long_str, sizeof(long_str), 5,
OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_2));
/* Test 2-byte-unsigned-int output with different output widths */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_2));
CALL(od(long_str, sizeof(long_str), 5,
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_2));
/* Test 2-byte-hex output with different output widths */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_2));
CALL(od(long_str, sizeof(long_str), 5,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_2));
/* Test different 4-byte-wise byte formats */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_4));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_4));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_4));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_4));
/* Test different 8-byte-wise byte formats */
#ifndef MODULE_NEWLIB
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_8));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_8));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_8));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_8));
#endif
/* Test different char-wise byte formats */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_CHAR));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_CHAR));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_CHAR));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_CHAR));
/* Test different short-wise byte formats */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_SHORT));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_SHORT));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_SHORT));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_SHORT));
/* Test different long-wise byte formats */
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_LONG));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_LONG));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_LONG));
CALL(od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT,
OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_LONG));
CALL(od_hex_dump(long_str, sizeof(long_str), OD_WIDTH_DEFAULT));
CALL(od_hex_dump(long_str, sizeof(long_str), 4));
CALL(od_hex_dump(long_str, sizeof(long_str), 3));
CALL(od_hex_dump(long_str, sizeof(long_str), 8));
return 0;
}

View File

@ -13,273 +13,30 @@ sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
import testrunner
def testfunc(child):
# check if running with newlib
print("ATTENTION: This script is currently not suitable for non-native platforms")
# test data width vs. output width discrepency
child.expect_exact(r'od(short_str, sizeof(short_str), OD_WIDTH_DEFAULT, 0)')
child.expect_exact(r'000000000 000000041101')
# Test different output width in default configuration
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, 0)')
child.expect_exact(r'000000000 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r'000000020 016033667155 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), 4, 0)')
child.expect_exact(r'000000000 037730226377')
child.expect_exact(r'000000004 014430661056')
child.expect_exact(r'000000010 015031663145')
child.expect_exact(r'000000014 015432665151')
child.expect_exact(r'000000020 016033667155')
child.expect_exact(r'000000024 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), 3, 0)')
child.expect_exact(r'000000000 037730226377')
child.expect_exact(r'000000004 014430661056')
child.expect_exact(r'000000010 015031663145')
child.expect_exact(r'000000014 015432665151')
child.expect_exact(r'000000020 016033667155')
child.expect_exact(r'000000024 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), 8, 0)')
child.expect_exact(r'000000000 037730226377 014430661056')
child.expect_exact(r'000000010 015031663145 015432665151')
child.expect_exact(r'000000020 016033667155 000000000000')
# Test different address formats in default configuration
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_ADDRESS_OCTAL)')
child.expect_exact(r'000000000 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r'000000020 016033667155 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_ADDRESS_HEX)')
child.expect_exact(r'000000 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r'000010 016033667155 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_ADDRESS_DECIMAL)')
child.expect_exact(r'0000000 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r'0000016 016033667155 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_ADDRESS_NONE)')
child.expect_exact(r' 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r' 016033667155 000000000000')
# Test octal data format with different address formats
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_OCTAL)')
child.expect_exact(r'000000000 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r'000000020 016033667155 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_ADDRESS_OCTAL | OD_FLAGS_BYTES_OCTAL)')
child.expect_exact(r'000000000 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r'000000020 016033667155 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_ADDRESS_HEX | OD_FLAGS_BYTES_OCTAL)')
child.expect_exact(r'000000 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r'000010 016033667155 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_ADDRESS_DECIMAL | OD_FLAGS_BYTES_OCTAL)')
child.expect_exact(r'0000000 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r'0000016 016033667155 000000000000')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_ADDRESS_NONE | OD_FLAGS_BYTES_OCTAL)')
child.expect_exact(r' 037730226377 014430661056 015031663145 015432665151')
child.expect_exact(r' 016033667155 000000000000')
# Test different data formats
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_CHAR)')
child.expect_exact(r'000000000 377 , a 377 . b c d e f g h i j k l')
child.expect_exact(r'000000020 m n o p \0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_INT)')
child.expect_exact(r'000000000 -10408705 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_DECIMAL)')
child.expect_exact(r'000000000 -10408705 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_UINT)')
child.expect_exact(r'000000000 4284558591 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_HEX)')
child.expect_exact(r'000000000 ff612cff 6463622e 68676665 6c6b6a69')
child.expect_exact(r'000000020 706f6e6d 00000000')
# Test octal byte-wise output with different output lengths
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 377 054 141 377 056 142 143 144 145 146 147 150 151 152 153 154')
child.expect_exact(r'000000020 155 156 157 160 000')
child.expect_exact(r'od(long_str, sizeof(long_str), 4, OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 377 054 141 377')
child.expect_exact(r'000000004 056 142 143 144')
child.expect_exact(r'000000010 145 146 147 150')
child.expect_exact(r'000000014 151 152 153 154')
child.expect_exact(r'000000020 155 156 157 160')
child.expect_exact(r'000000024 000')
child.expect_exact(r'od(long_str, sizeof(long_str), 3, OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 377 054 141')
child.expect_exact(r'000000003 377 056 142')
child.expect_exact(r'000000006 143 144 145')
child.expect_exact(r'000000011 146 147 150')
child.expect_exact(r'000000014 151 152 153')
child.expect_exact(r'000000017 154 155 156')
child.expect_exact(r'000000022 157 160 000')
child.expect_exact(r'od(long_str, sizeof(long_str), 8, OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 377 054 141 377 056 142 143 144')
child.expect_exact(r'000000010 145 146 147 150 151 152 153 154')
child.expect_exact(r'000000020 155 156 157 160 000')
# Test different data formats with byte-wise output
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_CHAR | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 377 , a 377 . b c d e f g h i j k l')
child.expect_exact(r'000000020 m n o p \0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 -1 44 97 -1 46 98 99 100 101 102 103 104 105 106 107 108')
child.expect_exact(r'000000020 109 110 111 112 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 -1 44 97 -1 46 98 99 100 101 102 103 104 105 106 107 108')
child.expect_exact(r'000000020 109 110 111 112 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 255 44 97 255 46 98 99 100 101 102 103 104 105 106 107 108')
child.expect_exact(r'000000020 109 110 111 112 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_1)')
child.expect_exact(r'000000000 ff 2c 61 ff 2e 62 63 64 65 66 67 68 69 6a 6b 6c')
child.expect_exact(r'000000020 6d 6e 6f 70 00')
# Test octal 2-byte-wise output with different output lengths
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 026377 177541 061056 062143 063145 064147 065151 066153')
child.expect_exact(r'000000020 067155 070157 000000')
child.expect_exact(r'od(long_str, sizeof(long_str), 4, OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 026377 177541')
child.expect_exact(r'000000004 061056 062143')
child.expect_exact(r'000000010 063145 064147')
child.expect_exact(r'000000014 065151 066153')
child.expect_exact(r'000000020 067155 070157')
child.expect_exact(r'000000024 000000')
child.expect_exact(r'od(long_str, sizeof(long_str), 3, OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 026377')
child.expect_exact(r'000000002 177541')
child.expect_exact(r'000000004 061056')
child.expect_exact(r'000000006 062143')
child.expect_exact(r'000000010 063145')
child.expect_exact(r'000000012 064147')
child.expect_exact(r'000000014 065151')
child.expect_exact(r'000000016 066153')
child.expect_exact(r'000000020 067155')
child.expect_exact(r'000000022 070157')
child.expect_exact(r'000000024 000000')
child.expect_exact(r'od(long_str, sizeof(long_str), 8, OD_FLAGS_BYTES_OCTAL | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 026377 177541 061056 062143')
child.expect_exact(r'000000010 063145 064147 065151 066153')
child.expect_exact(r'000000020 067155 070157 000000')
# Test 2-byte-char output (should just return normal char output)
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_CHAR | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 377 , a 377 . b c d e f g h i j k l')
child.expect_exact(r'000000020 m n o p \0')
# Test 2-byte-int output with different output widths
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 11519 -159 25134 25699 26213 26727 27241 27755')
child.expect_exact(r'000000020 28269 28783 0')
child.expect_exact(r'od(long_str, sizeof(long_str), 5, OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 11519 -159')
child.expect_exact(r'000000004 25134 25699')
child.expect_exact(r'000000010 26213 26727')
child.expect_exact(r'000000014 27241 27755')
child.expect_exact(r'000000020 28269 28783')
child.expect_exact(r'000000024 0')
# Test 2-byte-decimal output with different output widths
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 11519 -159 25134 25699 26213 26727 27241 27755')
child.expect_exact(r'000000020 28269 28783 0')
child.expect_exact(r'od(long_str, sizeof(long_str), 5, OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 11519 -159')
child.expect_exact(r'000000004 25134 25699')
child.expect_exact(r'000000010 26213 26727')
child.expect_exact(r'000000014 27241 27755')
child.expect_exact(r'000000020 28269 28783')
child.expect_exact(r'000000024 0')
# Test 2-byte-unsigned-int output with different output widths
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 11519 65377 25134 25699 26213 26727 27241 27755')
child.expect_exact(r'000000020 28269 28783 0')
child.expect_exact(r'od(long_str, sizeof(long_str), 5, OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 11519 65377')
child.expect_exact(r'000000004 25134 25699')
child.expect_exact(r'000000010 26213 26727')
child.expect_exact(r'000000014 27241 27755')
child.expect_exact(r'000000020 28269 28783')
child.expect_exact(r'000000024 0')
# Test 2-byte-hex output with different output widths
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 2cff ff61 622e 6463 6665 6867 6a69 6c6b')
child.expect_exact(r'000000020 6e6d 706f 0000')
child.expect_exact(r'od(long_str, sizeof(long_str), 5, OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_2)')
child.expect_exact(r'000000000 2cff ff61')
child.expect_exact(r'000000004 622e 6463')
child.expect_exact(r'000000010 6665 6867')
child.expect_exact(r'000000014 6a69 6c6b')
child.expect_exact(r'000000020 6e6d 706f')
child.expect_exact(r'000000024 0000')
# Test different 4-byte-wise byte formats
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_4)')
child.expect_exact(r'000000000 -10408705 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_4)')
child.expect_exact(r'000000000 -10408705 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_4)')
child.expect_exact(r'000000000 4284558591 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_4)')
child.expect_exact(r'000000000 ff612cff 6463622e 68676665 6c6b6a69')
child.expect_exact(r'000000020 706f6e6d 00000000')
# Test different 8-byte-wise byte formats
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_8)')
child.expect_exact(r'000000000 7233733380479724799 7812454979559974501')
child.expect_exact(r'000000020 1886350957')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_8)')
child.expect_exact(r'000000000 7233733380479724799 7812454979559974501')
child.expect_exact(r'000000020 1886350957')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_8)')
child.expect_exact(r'000000000 7233733380479724799 7812454979559974501')
child.expect_exact(r'000000020 1886350957')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_8)')
child.expect_exact(r'000000000 6463622eff612cff 6c6b6a6968676665')
child.expect_exact(r'000000020 00000000706f6e6d')
# Test different char-wise byte formats
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_CHAR)')
child.expect_exact(r'000000000 -1 44 97 -1 46 98 99 100 101 102 103 104 105 106 107 108')
child.expect_exact(r'000000020 109 110 111 112 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_CHAR)')
child.expect_exact(r'000000000 -1 44 97 -1 46 98 99 100 101 102 103 104 105 106 107 108')
child.expect_exact(r'000000020 109 110 111 112 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_CHAR)')
child.expect_exact(r'000000000 255 44 97 255 46 98 99 100 101 102 103 104 105 106 107 108')
child.expect_exact(r'000000020 109 110 111 112 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_CHAR)')
child.expect_exact(r'000000000 ff 2c 61 ff 2e 62 63 64 65 66 67 68 69 6a 6b 6c')
child.expect_exact(r'000000020 6d 6e 6f 70 00')
# Test different short-wise byte formats
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_SHORT)')
child.expect_exact(r'000000000 11519 -159 25134 25699 26213 26727 27241 27755')
child.expect_exact(r'000000020 28269 28783 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_SHORT)')
child.expect_exact(r'000000000 11519 -159 25134 25699 26213 26727 27241 27755')
child.expect_exact(r'000000020 28269 28783 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_SHORT)')
child.expect_exact(r'000000000 11519 65377 25134 25699 26213 26727 27241 27755')
child.expect_exact(r'000000020 28269 28783 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_SHORT)')
child.expect_exact(r'000000000 2cff ff61 622e 6463 6665 6867 6a69 6c6b')
child.expect_exact(r'000000020 6e6d 706f 0000')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_INT | OD_FLAGS_LENGTH_LONG)')
child.expect_exact(r'000000000 -10408705 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_DECIMAL | OD_FLAGS_LENGTH_LONG)')
child.expect_exact(r'000000000 -10408705 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_UINT | OD_FLAGS_LENGTH_LONG)')
child.expect_exact(r'000000000 4284558591 1684234798 1751606885 1818978921')
child.expect_exact(r'000000020 1886350957 0')
child.expect_exact(r'od(long_str, sizeof(long_str), OD_WIDTH_DEFAULT, OD_FLAGS_BYTES_HEX | OD_FLAGS_LENGTH_LONG)')
child.expect_exact(r'000000000 ff612cff 6463622e 68676665 6c6b6a69')
child.expect_exact(r'000000020 706f6e6d 00000000')
child.expect_exact("od_hex_dump(short_str, sizeof(short_str), OD_WIDTH_DEFAULT)")
child.expect_exact("00000000 41 42 00")
child.expect_exact("od_hex_dump(long_str, sizeof(long_str), OD_WIDTH_DEFAULT)")
child.expect_exact("00000000 FF 2C 61 FF 2E 62 63 64 65 66 67 68 69 6A 6B 6C")
child.expect_exact("00000010 6D 6E 6F 70 00")
child.expect_exact("od_hex_dump(long_str, sizeof(long_str), 4)")
child.expect_exact("00000000 FF 2C 61 FF")
child.expect_exact("00000004 2E 62 63 64")
child.expect_exact("00000008 65 66 67 68")
child.expect_exact("0000000C 69 6A 6B 6C")
child.expect_exact("00000010 6D 6E 6F 70")
child.expect_exact("00000014 00")
child.expect_exact("od_hex_dump(long_str, sizeof(long_str), 3)")
child.expect_exact("00000000 FF 2C 61")
child.expect_exact("00000003 FF 2E 62")
child.expect_exact("00000006 63 64 65")
child.expect_exact("00000009 66 67 68")
child.expect_exact("0000000C 69 6A 6B")
child.expect_exact("0000000F 6C 6D 6E")
child.expect_exact("00000012 6F 70 00")
child.expect_exact("od_hex_dump(long_str, sizeof(long_str), 8)")
child.expect_exact("00000000 FF 2C 61 FF 2E 62 63 64")
child.expect_exact("00000008 65 66 67 68 69 6A 6B 6C")
child.expect_exact("00000010 6D 6E 6F 70 00")
print("All tests successful")