forked from Archive/PX4-Autopilot
tests:Use inttypes
This commit is contained in:
parent
f3624c172c
commit
fd68fd2933
|
@ -52,12 +52,12 @@ int test_adc(int argc, char *argv[])
|
|||
px4_usleep(50000); // sleep 50ms and wait for adc report
|
||||
|
||||
if (_adc_sub.update(&adc)) {
|
||||
PX4_INFO_RAW("DeviceID: %d\n", adc.device_id);
|
||||
PX4_INFO_RAW("Resolution: %d\n", adc.resolution);
|
||||
PX4_INFO_RAW("DeviceID: %" PRIu32 "\n", adc.device_id);
|
||||
PX4_INFO_RAW("Resolution: %" PRIu32 "\n", adc.resolution);
|
||||
PX4_INFO_RAW("Voltage Reference: %f\n", adc.v_ref);
|
||||
|
||||
for (int i = 0; i < PX4_MAX_ADC_CHANNELS; ++i) {
|
||||
PX4_INFO_RAW("%d: %d ", adc.channel_id[i], adc.raw_data[i]);
|
||||
PX4_INFO_RAW("%" PRIu16 ": %" PRIi32 " ", adc.channel_id[i], adc.raw_data[i]);
|
||||
}
|
||||
|
||||
PX4_INFO_RAW("\n");
|
||||
|
|
|
@ -124,7 +124,7 @@ decode_callback(bson_decoder_t decoder, void *priv, bson_node_t node)
|
|||
}
|
||||
|
||||
if (node->i != sample_small_int) {
|
||||
PX4_ERR("FAIL: decoder: int1 value %" PRIu64 ", expected %d", node->i, sample_small_int);
|
||||
PX4_ERR("FAIL: decoder: int1 value %" PRIu64 ", expected %" PRIi32 "", node->i, sample_small_int);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <px4_platform_common/defines.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
|
@ -70,8 +71,8 @@ static uint8_t get_value(uint32_t ofs)
|
|||
|
||||
static int test_corruption(const char *filename, uint32_t write_chunk, uint32_t write_size, uint16_t flags)
|
||||
{
|
||||
printf("Testing on %s with write_chunk=%u write_size=%u\n",
|
||||
filename, (unsigned)write_chunk, (unsigned)write_size);
|
||||
printf("Testing on %s with write_chunk=%" PRIu32 " write_size=%" PRIu32 "\n",
|
||||
filename, write_chunk, write_size);
|
||||
|
||||
uint32_t ofs = 0;
|
||||
int fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, PX4_O_MODE_666);
|
||||
|
@ -93,7 +94,7 @@ static int test_corruption(const char *filename, uint32_t write_chunk, uint32_t
|
|||
}
|
||||
|
||||
if (write(fd, buffer, sizeof(buffer)) != (int)sizeof(buffer)) {
|
||||
printf("write failed at offset %u\n", ofs);
|
||||
printf("write failed at offset %" PRIu32 "\n", ofs);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,7 @@ static int test_corruption(const char *filename, uint32_t write_chunk, uint32_t
|
|||
}
|
||||
|
||||
if (counter % 100 == 0) {
|
||||
printf("write ofs=%u\r", ofs);
|
||||
printf("write ofs=%" PRIu32 "\r", ofs);
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
@ -110,7 +111,7 @@ static int test_corruption(const char *filename, uint32_t write_chunk, uint32_t
|
|||
|
||||
close(fd);
|
||||
|
||||
printf("write ofs=%u\n", ofs);
|
||||
printf("write ofs=%" PRIu32 "\n", ofs);
|
||||
|
||||
// read and check
|
||||
fd = open(filename, O_RDONLY);
|
||||
|
@ -127,20 +128,20 @@ static int test_corruption(const char *filename, uint32_t write_chunk, uint32_t
|
|||
uint8_t buffer[write_chunk];
|
||||
|
||||
if (counter % 100 == 0) {
|
||||
printf("read ofs=%u\r", ofs);
|
||||
printf("read ofs=%" PRIu32 "\r", ofs);
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if (read(fd, buffer, sizeof(buffer)) != (int)sizeof(buffer)) {
|
||||
printf("read failed at offset %u\n", ofs);
|
||||
printf("read failed at offset %" PRIu32 "\n", ofs);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (uint16_t j = 0; j < write_chunk; j++) {
|
||||
if (buffer[j] != get_value(ofs)) {
|
||||
printf("corruption at ofs=%u got %u\n", ofs, buffer[j]);
|
||||
printf("corruption at ofs=%" PRIu32 " got %" PRIu8 "\n", ofs, buffer[j]);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
@ -153,7 +154,7 @@ static int test_corruption(const char *filename, uint32_t write_chunk, uint32_t
|
|||
}
|
||||
}
|
||||
|
||||
printf("read ofs=%u\n", ofs);
|
||||
printf("read ofs=%" PRIu32 "\n", ofs);
|
||||
close(fd);
|
||||
unlink(filename);
|
||||
printf("All OK\n");
|
||||
|
|
|
@ -52,14 +52,14 @@ int test_jig_voltages(int argc, char *argv[])
|
|||
px4_usleep(50000); // sleep 50ms and wait for adc report
|
||||
|
||||
if (_adc_sub.update(&adc)) {
|
||||
PX4_INFO_RAW("DeviceID: %d\n", adc.device_id);
|
||||
PX4_INFO_RAW("Resolution: %d\n", adc.resolution);
|
||||
PX4_INFO_RAW("DeviceID: %" PRIu32 "\n", adc.device_id);
|
||||
PX4_INFO_RAW("Resolution: %" PRIu32 "\n", adc.resolution);
|
||||
PX4_INFO_RAW("Voltage Reference: %f\n", adc.v_ref);
|
||||
|
||||
unsigned channels = 0;
|
||||
|
||||
for (int i = 0; i < PX4_MAX_ADC_CHANNELS; ++i) {
|
||||
PX4_INFO_RAW("%d: %d ", adc.channel_id[i], adc.raw_data[i]);
|
||||
PX4_INFO_RAW("%" PRIu16 ": %" PRIi32 " ", adc.channel_id[i], adc.raw_data[i]);
|
||||
|
||||
if (adc.channel_id[i] != -1) {
|
||||
++channels;
|
||||
|
|
|
@ -123,7 +123,7 @@ int test_time(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
printf("Maximum jitter %" PRId64 "us\n", maxdelta);
|
||||
printf("Maximum jitter %dus\n", maxdelta);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -60,13 +60,15 @@ bool VersioningTest::_test_tag_to_version_number(const char *version_tag, uint32
|
|||
return true;
|
||||
|
||||
} else {
|
||||
PX4_ERR("Wrong vendor version: tag: %s, got: 0x%x, expected: 0x%x", version_tag, vendor_version_result,
|
||||
PX4_ERR("Wrong vendor version: tag: %s, got: 0x%" PRIx32 ", expected: 0x%" PRIx32 "", version_tag,
|
||||
vendor_version_result,
|
||||
vendor_version_target);
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
PX4_ERR("Wrong flight version: tag: %s, got: 0x%x, expected: 0x%x", version_tag, flight_version_result,
|
||||
PX4_ERR("Wrong flight version: tag: %s, got: 0x%" PRIx32 ", expected: 0x%" PRIx32 "", version_tag,
|
||||
flight_version_result,
|
||||
flight_version_target);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue