Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
359 changes: 230 additions & 129 deletions testcases/Kconfig

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions testcases/abnormal_test/abnormal_test.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROGNAME += abnormal_test_backtrace
MAINSRC += $(CURDIR)/abnormal_test/backtrace_test.c
41 changes: 41 additions & 0 deletions testcases/abnormal_test/backtrace_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <nuttx/config.h>
#include <time.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

/****************************************************************************
* Name: creat
* Example description:
1. Actively trigger a segmentation fault.
2. Test the function of backtrace.
****************************************************************************/

int main(int argc, FAR char *argv[])
{
int delay_time = 0;
// char *buf = NULL;
if (argc == 3)
{
if (strcmp("-t", argv[1]) == 0)
{
delay_time = atoi(argv[2]);
}
}
else
{
printf("The argument is wrong !\n");
printf("usage CMD [-t Delay time] & \n");
exit(1);
}

/* How long to wait */
sleep(delay_time);

/* Visit NULL address, Trigger segfault */
// memset(buf, 'A', 1);

return 0;
}
Binary file not shown.
Binary file not shown.
85 changes: 85 additions & 0 deletions testcases/fdcheck_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# ##############################################################################
# apps/tests/testcases/fdcheck_test/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for

# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_FDCHECK_TEST)
nuttx_add_application(
NAME
fdcheck_test_common
PRIORITY
${CONFIG_TESTING_TESTCASES_PRIORITY}
STACKSIZE
${CONFIG_TESTING_TESTCASES_STACKSIZE}
SRCS
fdcheck_test_common.c)
nuttx_add_application(
NAME
fdcheck_test_thread
PRIORITY
${CONFIG_TESTING_TESTCASES_PRIORITY}
STACKSIZE
${CONFIG_TESTING_TESTCASES_STACKSIZE}
SRCS
fdcheck_test_thread.c)
nuttx_add_application(
NAME
fdcheck_test_select
PRIORITY
${CONFIG_TESTING_TESTCASES_PRIORITY}
STACKSIZE
${CONFIG_TESTING_TESTCASES_STACKSIZE}
SRCS
fdcheck_test_select.c)
nuttx_add_application(
NAME
fdcheck_test_socket
PRIORITY
${CONFIG_TESTING_TESTCASES_PRIORITY}
STACKSIZE
${CONFIG_TESTING_TESTCASES_STACKSIZE}
SRCS
fdcheck_test_socket.c)
nuttx_add_application(
NAME
fdcheck_test_pipe
PRIORITY
${CONFIG_TESTING_TESTCASES_PRIORITY}
STACKSIZE
${CONFIG_TESTING_TESTCASES_STACKSIZE}
SRCS
fdcheck_test_pipe.c)
nuttx_add_application(
NAME
fdcheck_test_fork
PRIORITY
${CONFIG_TESTING_TESTCASES_PRIORITY}
STACKSIZE
${CONFIG_TESTING_TESTCASES_STACKSIZE}
SRCS
fdcheck_test_fork.c)
nuttx_add_application(
NAME
fdcheck_test_socket_server
PRIORITY
${CONFIG_TESTING_TESTCASES_PRIORITY}
STACKSIZE
${CONFIG_TESTING_TESTCASES_STACKSIZE}
SRCS
fdcheck_test_socket_server.c)
endif()
14 changes: 14 additions & 0 deletions testcases/fdcheck_test/fdcheck_test.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PROGNAME += fdcheck_test_common
MAINSRC += $(CURDIR)/fdcheck_test/fdcheck_test_common.c
PROGNAME += fdcheck_test_thread
MAINSRC += $(CURDIR)/fdcheck_test/fdcheck_test_thread.c
PROGNAME += fdcheck_test_select
MAINSRC += $(CURDIR)/fdcheck_test/fdcheck_test_select.c
PROGNAME += fdcheck_test_socket
MAINSRC += $(CURDIR)/fdcheck_test/fdcheck_test_socket.c
PROGNAME += fdcheck_test_pipe
MAINSRC += $(CURDIR)/fdcheck_test/fdcheck_test_pipe.c
PROGNAME += fdcheck_test_fork
MAINSRC += $(CURDIR)/fdcheck_test/fdcheck_test_fork.c
PROGNAME += fdcheck_test_socket_server
MAINSRC += $(CURDIR)/fdcheck_test/fdcheck_test_socket_server.c
22 changes: 22 additions & 0 deletions testcases/fdcheck_test/fdcheck_test_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <nuttx/config.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <syslog.h>
#include <sys/stat.h>

int main(int argc, char **argv)
{
int fd1, fd2;

fd1 = open("/dev/null", O_RDONLY);
close(fd1);

fd2 = open("/dev/null", O_RDONLY);
close(fd1); // fdcheck will throw Assertion failed panic here
syslog(0, "fd1 %d fd2 %d\n", fd1, fd2);
syslog(0, "TEST FAILED\n");

return 0;
}
31 changes: 31 additions & 0 deletions testcases/fdcheck_test/fdcheck_test_fork.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <nuttx/config.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <syslog.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>

int main(int argc, char **argv)
{
int fd1, fd2 = 0;
fd1 = open("/dev/null", O_RDONLY);
close(fd1);
pid_t pid = fork();
if (pid > 0) {
int status;
waitpid(pid, &status, 0);
syslog(0, "pid:%d, status:%d\n", pid, status);
} else if (pid == 0) {
syslog(0, "here is father process\n");
fd2 = open("/dev/null", O_RDONLY);
close(fd1);
} else {
syslog(0, "fork failed\n");
return 0;
}
syslog(0, "fd1 %d fd2 %d\n", fd1, fd2);
return 0;
}
37 changes: 37 additions & 0 deletions testcases/fdcheck_test/fdcheck_test_pipe.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <nuttx/config.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <syslog.h>
#include <sys/stat.h>

#define MAX_MSGSIZE 1000

int main(int argc, char **argv)
{
int pipefd1[2], pipefd2[2];
char msg[MAX_MSGSIZE];

if (pipe(pipefd1) != 0) {
syslog(LOG_ERR, "pipe failed\n");
return -1;
}

write(pipefd1[1], "vela", 5);
read(pipefd1[0], msg, MAX_MSGSIZE);
syslog(0, "%s", msg);

close(pipefd1[1]);
close(pipefd1[0]);

if (pipe(pipefd2) != 0) {
syslog(LOG_ERR, "pipe failed\n");
return -1;
}

read(pipefd1[0], msg, MAX_MSGSIZE);

syslog(0, "TEST FAILED\n");
return 0;
}
Loading
Loading