Skip to content
18 changes: 15 additions & 3 deletions examples/fb/fb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
int ret;
uintptr_t buf_offset;
struct fb_planeinfo_s pinfo;
FAR void *fbmem;

memset(&pinfo, 0, sizeof(pinfo));
pinfo.display = state->pinfo.display + 1;
Expand All @@ -207,6 +208,17 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
return EXIT_FAILURE;
}

fbmem = mmap(NULL, pinfo.fblen, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_FILE, state->fd, 0);

if (fbmem == MAP_FAILED)
{
int errcode = errno;
fprintf(stderr, "ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n",
errcode);
return EXIT_FAILURE;
}

/* Check bpp */

if (pinfo.bpp != state->pinfo.bpp)
Expand All @@ -219,7 +231,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
* It needs to be divisible by pinfo.stride
*/

buf_offset = pinfo.fbmem - state->fbmem;
buf_offset = fbmem - state->fbmem;

if ((buf_offset % state->pinfo.stride) != 0)
{
Expand All @@ -236,7 +248,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
/* Use consecutive fbmem2. */

state->mem2_yoffset = state->vinfo.yres;
state->fbmem2 = pinfo.fbmem + state->mem2_yoffset * pinfo.stride;
state->fbmem2 = fbmem + state->mem2_yoffset * pinfo.stride;
printf("Use consecutive fbmem2 = %p, yoffset = %" PRIu32"\n",
state->fbmem2, state->mem2_yoffset);
}
Expand All @@ -245,7 +257,7 @@ static int fb_init_mem2(FAR struct fb_state_s *state)
/* Use non-consecutive fbmem2. */

state->mem2_yoffset = buf_offset / state->pinfo.stride;
state->fbmem2 = pinfo.fbmem;
state->fbmem2 = fbmem;
printf("Use non-consecutive fbmem2 = %p, yoffset = %" PRIu32"\n",
state->fbmem2, state->mem2_yoffset);
}
Expand Down
2 changes: 2 additions & 0 deletions netutils/iperf/iperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,15 @@ static void iperf_print_addr(FAR const char *str, FAR struct sockaddr *addr)
{
switch (addr->sa_family)
{
#ifdef CONFIG_NET_IPv4
case AF_INET:
{
FAR struct sockaddr_in *inaddr = (FAR struct sockaddr_in *)addr;
printf("%s: %s:%d\n", str,
inet_ntoa(inaddr->sin_addr), htons(inaddr->sin_port));
return;
}
#endif

case AF_LOCAL:
{
Expand Down
8 changes: 8 additions & 0 deletions netutils/iperf/iperf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ int main(int argc, FAR char *argv[])
struct iperf_cfg_t cfg;
struct in_addr addr;
int nerrors;

#ifdef CONFIG_NET_IPv4
char inetaddr[INET_ADDRSTRLEN];
#endif

bzero(&addr, sizeof(struct in_addr));
bzero(&cfg, sizeof(cfg));
Expand Down Expand Up @@ -226,6 +229,7 @@ int main(int argc, FAR char *argv[])
}
else
{
#ifdef CONFIG_NET_IPv4
if (iperf_args.bind->count > 0)
{
addr.s_addr = inet_addr(iperf_args.bind->sval[0]);
Expand All @@ -248,6 +252,10 @@ int main(int argc, FAR char *argv[])
printf(" IP: %s\n", inet_ntoa_r(addr, inetaddr, sizeof(inetaddr)));

cfg.sip = addr.s_addr;
#else
printf("ERROR: IPv4 Not Enabled\n");
goto out;
#endif
}

if (iperf_args.udp->count == 0)
Expand Down
5 changes: 4 additions & 1 deletion system/libuv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ if(CONFIG_LIBUV)
${LIBUV_UNIX_DIR}/fs.c
${LIBUV_SRC_DIR}/fs-poll.c
${LIBUV_SRC_DIR}/timer.c
${LIBUV_UNIX_DIR}/process-spawn.c
${LIBUV_UNIX_DIR}/sysinfo-loadavg.c
${LIBUV_UNIX_DIR}/sysinfo-memory.c)

if(CONFIG_LIBC_EXECFUNCS)
list(APPEND SRCS ${LIBUV_UNIX_DIR}/process-spawn.c)
endif()

if(CONFIG_LIBC_DLFCN)
list(APPEND SRCS ${LIBUV_UNIX_DIR}/dl.c)
endif()
Expand Down
4 changes: 2 additions & 2 deletions testing/drivers/drivertest/drivertest_pm_smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@

#define TEST_PM_LOOP_COUNT 5

#define TEST_STAYTIMEOUT 2 /* in ms */
#define TEST_STAYTIMEOUT 20 /* in ms */

#define TEST_SNAP_TICK_MAX 3
#define TEST_SNAP_TICK_MAX 5

#define TEST_TIMEOUT_ENABLED 1

Expand Down
20 changes: 20 additions & 0 deletions testing/drivers/drivertest/drivertest_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <cmocka.h>
Expand Down Expand Up @@ -70,6 +71,7 @@ struct test_confs_s
struct test_state_s
{
FAR const char *dev_path;
struct termios devtio; /* Original serial port setting */
FAR char *buffer;
int fd;
};
Expand Down Expand Up @@ -170,6 +172,8 @@ static int setup(FAR void **state)
{
FAR struct test_confs_s *confs = (FAR struct test_confs_s *)*state;
FAR struct test_state_s *test_state = malloc(sizeof(struct test_state_s));
struct termios ti;
int ret = 0;
assert_true(test_state != NULL);

test_state->dev_path = confs->dev_path;
Expand All @@ -180,6 +184,16 @@ static int setup(FAR void **state)
test_state->fd = open(test_state->dev_path, O_RDWR);
assert_true(test_state->fd > 0);

ret = tcgetattr(test_state->fd, &ti);
assert_int_equal(ret, OK);

/* Backup and enable data to be processed as raw input */

memcpy(&test_state->devtio, &ti, sizeof(struct termios));
cfmakeraw(&ti);
ret = tcsetattr(test_state->fd, TCSANOW, &ti);
assert_int_equal(ret, OK);

*state = test_state;
return 0;
}
Expand All @@ -191,6 +205,12 @@ static int setup(FAR void **state)
static int teardown(FAR void **state)
{
FAR struct test_state_s *test_state = (FAR struct test_state_s *)*state;
int ret = 0;

/* Retrieve termios updated flags */

ret = tcsetattr(test_state->fd, TCSANOW, &test_state->devtio);
assert_int_equal(ret, OK);

free(test_state->buffer);
assert_int_equal(close(test_state->fd), 0);
Expand Down
4 changes: 2 additions & 2 deletions testing/ostest/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ endif

config TESTING_OSTEST_RR_RANGE
int "Round-robin test - end of search range"
default 10000
default 30000
range 1 32767
---help---
During round-robin scheduling test two threads are created. Each of the threads
Expand All @@ -62,7 +62,7 @@ config TESTING_OSTEST_RR_RANGE

This value specifies the end of search range and together with number of runs
allows to configure the length of this test - it should last at least a few
tens of seconds. Allowed values [1; 32767], default 10000
tens of seconds. Allowed values [1; 32767], default 30000

config TESTING_OSTEST_RR_RUNS
int "Round-robin test - number of runs"
Expand Down
47 changes: 45 additions & 2 deletions testing/ostest/roundrobin.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
* Private Data
****************************************************************************/

static uint8_t g_rr_values[CONFIG_TESTING_OSTEST_RR_RUNS * 2];
static atomic_t g_rr_value_index;
static sem_t g_rrsem;

/****************************************************************************
Expand Down Expand Up @@ -132,6 +134,7 @@ static FAR void *get_primes_thread(FAR void *parameter)
for (i = 0; i < CONFIG_TESTING_OSTEST_RR_RUNS; i++)
{
get_primes(&count, &last);
g_rr_values[atomic_fetch_add(&g_rr_value_index, 1)] = id;
}

printf("get_primes_thread id=%d finished, found %d primes, "
Expand All @@ -154,11 +157,16 @@ void rr_test(void)
pthread_t get_primes1_thread;
pthread_t get_primes2_thread;
struct sched_param sparam;
bool test_passed = false;
pthread_attr_t attr;
pthread_addr_t result;
#ifdef CONFIG_SMP
cpu_set_t cpuset;
#endif
int status;
int i;

/* Setup common thread attrributes */
/* Setup common thread attributes */

status = pthread_attr_init(&attr);
if (status != OK)
Expand Down Expand Up @@ -194,9 +202,25 @@ void rr_test(void)
printf("rr_test: Set thread policy to SCHED_RR\n");
}

#ifdef CONFIG_SMP
/* RR case on SMP only run on core0 */

CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset);
status = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset);
if (status != OK)
{
printf("rr_test: ERROR: pthread_attr_setaffinity_np failed,"
" status=%d\n", status);
ASSERT(false);
}
#endif

/* This semaphore will prevent anything from running until we are ready */

sched_lock();
atomic_set(&g_rr_value_index, 0);
memset(g_rr_values, 0, sizeof(g_rr_values));
sem_init(&g_rrsem, 0, 0);

/* Start the threads */
Expand Down Expand Up @@ -235,7 +259,26 @@ void rr_test(void)

pthread_join(get_primes2_thread, &result);
pthread_join(get_primes1_thread, &result);
printf("rr_test: Done\n");

for (i = 1; i < CONFIG_TESTING_OSTEST_RR_RUNS; i++)
{
if (g_rr_values[i - 1] != g_rr_values[i])
{
test_passed = true;
break;
}
}

if (test_passed)
{
printf("rr_test: Done\n");
}
else
{
printf("rr_test: Roundrobin Failed\n");
ASSERT(false);
}

sem_destroy(&g_rrsem);
}

Expand Down
39 changes: 8 additions & 31 deletions testing/testsuites/kernel/fs/cases/fs_stat_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,9 @@ void test_nuttx_fs_stat01(FAR void **state)

struct tm *tm_1 = NULL;
struct tm *tm_2 = NULL;
int year1;
int year2;
int month1;
int month2;
int day1;
int day2;
int hour1;
int hour2;
int min1;
int min2;
time_t t_1;
time_t t_2;
time_t t_diff;
struct fs_testsuites_state_s *test_state;

test_state = (struct fs_testsuites_state_s *)*state;
Expand Down Expand Up @@ -127,14 +118,6 @@ void test_nuttx_fs_stat01(FAR void **state)
tm_1 = gmtime(&t_1);
assert_non_null(tm_1);

/* set time */

year1 = tm_1->tm_year;
month1 = tm_1->tm_mon;
day1 = tm_1->tm_mday;
hour1 = tm_1->tm_hour;
min1 = tm_1->tm_min;

/* get file info */

ret = stat(TEST_FILE, &file_s);
Expand All @@ -144,23 +127,17 @@ void test_nuttx_fs_stat01(FAR void **state)

t_2 = file_s.st_mtime;
tm_2 = gmtime(&t_2);

assert_non_null(tm_2);

/* set time */
/* compare time */

t_diff = t_2 - t_1;

/* tolerance for 30s for worst case */

year2 = tm_2->tm_year;
month2 = tm_2->tm_mon;
day2 = tm_2->tm_mday;
hour2 = tm_2->tm_hour;
min2 = tm_2->tm_min;
assert_int_in_range(t_diff, -30, 30);

/* compare time and size */
/* compare size */

assert_int_equal(year1, year2);
assert_int_equal(month1, month2);
assert_int_equal(day1, day2);
assert_int_equal(hour1, hour2);
assert_int_equal(min1, min2);
assert_int_equal(file_s.st_size, BUF_SIZE);
}
2 changes: 2 additions & 0 deletions testing/testsuites/kernel/syscall/cmocka_syscall_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ int main(int argc, char *argv[])
test_nuttx_syscall_getpeername01,
test_nuttx_syscall_test_group_setup,
test_nuttx_syscall_test_group_teardown),
# ifdef CONFIG_NET_IPv4
cmocka_unit_test_setup_teardown(
test_nuttx_syscall_getsockopt01,
test_nuttx_syscall_test_group_setup,
Expand All @@ -175,6 +176,7 @@ int main(int argc, char *argv[])
test_nuttx_syscall_setsockopt01,
test_nuttx_syscall_test_group_setup,
test_nuttx_syscall_test_group_teardown),
# endif
cmocka_unit_test_setup_teardown(
test_nuttx_syscall_listen01,
test_nuttx_syscall_test_group_setup,
Expand Down
Loading