system/libuv: Bump to v1.42.0

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2021-04-01 19:12:59 +08:00 committed by Xiang Xiao
parent a79195a048
commit 9351ab50d5
16 changed files with 2182 additions and 8469 deletions

View File

@ -1,3 +1,2 @@
/Kconfig libuv*
libuv-*
*.zip *.zip

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

45
system/libuv/Kconfig Normal file
View File

@ -0,0 +1,45 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config LIBUV
bool "libuv asynchronous I/O Library"
default n
select PIPES
---help---
Enable build for libuv asynchronous I/O Library
if LIBUV
config LIBUV_THREADPOOL_SIZE
int "libuv default thread pool size"
default 1
choice
prompt "libuv utils"
default LIBUV_UTILS_NONE
config LIBUV_UTILS_NONE
bool "none"
config LIBUV_UTILS_TEST
bool "uv_run_tests"
config LIBUV_UTILS_BENCHMARK
bool "uv_run_benchmarks"
endchoice
if !LIBUV_UTILS_NONE
config LIBUV_UTILS_PRIORITY
int "libuv utils priority"
default 100
config LIBUV_UTILS_STACKSIZE
int "libuv utils stack size"
default 8192
endif
endif

View File

@ -18,15 +18,14 @@
# #
############################################################################ ############################################################################
# Set up build configuration and environment ifneq ($(CONFIG_LIBUV),)
CONFIGURED_APPS += $(APPDIR)/system/libuv
LIBUV_DIR := $(APPDIR)/system/libuv # Enable <uv.h> include.
CONFIG_LIBUV_URL ?= "https://github.com/libuv/libuv/archive" CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" \
CONFIG_LIBUV_VERSION ?= 1.38.1 $(APPDIR)/system/libuv/libuv/include}
CONFIG_LIBUV_TARBALL ?= v$(CONFIG_LIBUV_VERSION).zip CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" \
$(APPDIR)/system/libuv/libuv/include}
LIBUV_UNPACKNAME := libuv-$(CONFIG_LIBUV_VERSION) endif
LIBUV_UNPACKDIR := $(LIBUV_DIR)/$(LIBUV_UNPACKNAME)
include $(wildcard $(APPDIR)/system/libuv/*/Make.defs)

View File

@ -18,6 +18,305 @@
# #
############################################################################ ############################################################################
MENUDESC = "libuv async i/o Library" include $(APPDIR)/Make.defs
include $(APPDIR)/Directory.mk LIBUV_PATCHS ?= $(sort $(wildcard 000*.patch))
LIBUV_VERSION = 1.42.0
LIBUV_UNPACK = libuv
LIBUV_TARBALL = v$(LIBUV_VERSION).zip
LIBUV_URL_BASE = https://github.com/libuv/libuv/archive/refs/tags/
LIBUV_URL = $(LIBUV_URL_BASE)/$(LIBUV_TARBALL)
$(LIBUV_TARBALL):
@echo "Downloading: $(LIBUV_TARBALL)"
$(Q) curl -L $(LIBUV_URL) -o $(LIBUV_TARBALL)
$(LIBUV_UNPACK): $(LIBUV_TARBALL)
@echo "Unpacking: $(LIBUV_TARBALL) -> $(LIBUV_UNPACK)"
$(call DELDIR, $(LIBUV_UNPACK))
$(Q) unzip $(LIBUV_TARBALL)
$(Q) mv libuv-$(LIBUV_VERSION) $(LIBUV_UNPACK)
$(Q) cat $(LIBUV_PATCHS) | \
patch -s -N -d $(LIBUV_UNPACK) -p1
$(LIBUV_UNPACK)/.patch: $(LIBUV_UNPACK)
$(Q) touch $(LIBUV_UNPACK)/.patch
# Build libuv library
CFLAGS += -I$(LIBUV_UNPACK)/src
CFLAGS += -I$(LIBUV_UNPACK)/src/unix
CFLAGS += -I$(LIBUV_UNPACK)/test
CFLAGS += -Wno-shadow
CFLAGS += -DDEF_THREADPOOL_SIZE=CONFIG_LIBUV_THREADPOOL_SIZE
VPATH += $(LIBUV_UNPACK)/src
VPATH += $(LIBUV_UNPACK)/src/unix
VPATH += $(LIBUV_UNPACK)/test
DEPPATH += --dep-path $(LIBUV_UNPACK)/src
DEPPATH += --dep-path $(LIBUV_UNPACK)/src/unix
DEPPATH += --dep-path $(LIBUV_UNPACK)/test
CSRCS += core.c
CSRCS += poll.c
CSRCS += loop.c
CSRCS += thread.c
CSRCS += no-proctitle.c
CSRCS += posix-hrtime.c
CSRCS += posix-poll.c
CSRCS += uv-data-getter-setters.c
CSRCS += version.c
CSRCS += idna.c
CSRCS += no-fsevents.c
CSRCS += uv-common.c
CSRCS += strscpy.c
CSRCS += random-devurandom.c
CSRCS += random.c
CSRCS += nuttx.c
CSRCS += tty.c
CSRCS += loop-watcher.c
CSRCS += signal.c
CSRCS += stream.c
CSRCS += threadpool.c
CSRCS += async.c
CSRCS += pipe.c
CSRCS += fs.c
CSRCS += fs-poll.c
CSRCS += timer.c
CSRCS += process.c
ifneq ($(CONFIG_LIBC_DLFCN),)
CSRCS += dl.c
endif
ifneq ($(CONFIG_NET),)
CSRCS += getaddrinfo.c
CSRCS += getnameinfo.c
CSRCS += inet.c
endif
ifneq ($(CONFIG_NET_TCP),)
CSRCS += tcp.c
endif
ifneq ($(CONFIG_NET_UDP),)
CSRCS += udp.c
endif
PRIORITY = $(CONFIG_LIBUV_UTILS_PRIORITY)
STACKSIZE = $(CONFIG_LIBUV_UTILS_STACKSIZE)
ifneq ($(CONFIG_LIBUV_UTILS_TEST),)
PROGNAME = uv_run_tests
MAINSRC = run-tests.c
CSRCS += runner.c
CSRCS += runner-unix.c
CSRCS += echo-server.c
CSRCS += test-active.c
CSRCS += test-async.c
CSRCS += test-async-null-cb.c
CSRCS += test-barrier.c
CSRCS += test-callback-order.c
CSRCS += test-callback-stack.c
CSRCS += test-close-fd.c
CSRCS += test-close-order.c
CSRCS += test-condvar.c
CSRCS += test-connection-fail.c
CSRCS += test-connect-unspecified.c
CSRCS += test-cwd-and-chdir.c
CSRCS += test-default-loop-close.c
CSRCS += test-delayed-accept.c
CSRCS += test-dlerror.c
CSRCS += test-eintr-handling.c
CSRCS += test-embed.c
CSRCS += test-emfile.c
CSRCS += test-env-vars.c
CSRCS += test-error.c
CSRCS += test-fail-always.c
CSRCS += test-fs.c
CSRCS += test-fs-copyfile.c
CSRCS += test-fs-event.c
CSRCS += test-fs-fd-hash.c
CSRCS += test-fs-open-flags.c
CSRCS += test-fs-poll.c
CSRCS += test-fs-readdir.c
CSRCS += test-getaddrinfo.c
CSRCS += test-get-currentexe.c
CSRCS += test-gethostname.c
CSRCS += test-get-loadavg.c
CSRCS += test-get-memory.c
CSRCS += test-getnameinfo.c
CSRCS += test-get-passwd.c
CSRCS += test-getsockname.c
CSRCS += test-getters-setters.c
CSRCS += test-gettimeofday.c
CSRCS += test-handle-fileno.c
CSRCS += test-homedir.c
CSRCS += test-hrtime.c
CSRCS += test-idle.c
CSRCS += test-idna.c
CSRCS += test-ip4-addr.c
CSRCS += test-ip6-addr.c
CSRCS += test-ipc.c
CSRCS += test-ipc-heavy-traffic-deadlock-bug.c
CSRCS += test-ipc-send-recv.c
CSRCS += test-loop-alive.c
CSRCS += test-loop-close.c
CSRCS += test-loop-configure.c
CSRCS += test-loop-handles.c
CSRCS += test-loop-stop.c
CSRCS += test-loop-time.c
CSRCS += test-metrics.c
CSRCS += test-multiple-listen.c
CSRCS += test-mutexes.c
CSRCS += test-not-readable-nor-writable-on-read-error.c
CSRCS += test-not-readable-on-eof.c
CSRCS += test-not-writable-after-shutdown.c
CSRCS += test-osx-select.c
CSRCS += test-pass-always.c
CSRCS += test-ping-pong.c
CSRCS += test-pipe-bind-error.c
CSRCS += test-pipe-close-stdout-read-stdin.c
CSRCS += test-pipe-connect-error.c
CSRCS += test-pipe-connect-multiple.c
CSRCS += test-pipe-connect-prepare.c
CSRCS += test-pipe-getsockname.c
CSRCS += test-pipe-pending-instances.c
CSRCS += test-pipe-sendmsg.c
CSRCS += test-pipe-server-close.c
CSRCS += test-pipe-set-fchmod.c
CSRCS += test-pipe-set-non-blocking.c
CSRCS += test-platform-output.c
CSRCS += test-poll.c
CSRCS += test-poll-close.c
CSRCS += test-poll-close-doesnt-corrupt-stack.c
CSRCS += test-poll-closesocket.c
CSRCS += test-poll-multiple-handles.c
CSRCS += test-poll-oob.c
CSRCS += test-process-priority.c
CSRCS += test-process-title.c
CSRCS += test-process-title-threadsafe.c
CSRCS += test-queue-foreach-delete.c
CSRCS += test-random.c
CSRCS += test-ref.c
CSRCS += test-run-nowait.c
CSRCS += test-run-once.c
CSRCS += test-semaphore.c
CSRCS += test-shutdown-close.c
CSRCS += test-shutdown-eof.c
CSRCS += test-shutdown-simultaneous.c
CSRCS += test-shutdown-twice.c
CSRCS += test-signal.c
CSRCS += test-signal-multiple-loops.c
CSRCS += test-signal-pending-on-close.c
CSRCS += test-socket-buffer-size.c
CSRCS += test-spawn.c
CSRCS += test-stdio-over-pipes.c
CSRCS += test-strscpy.c
CSRCS += test-tcp-alloc-cb-fail.c
CSRCS += test-tcp-bind6-error.c
CSRCS += test-tcp-bind-error.c
CSRCS += test-tcp-close-accept.c
CSRCS += test-tcp-close.c
CSRCS += test-tcp-close-reset.c
CSRCS += test-tcp-close-while-connecting.c
CSRCS += test-tcp-connect6-error.c
CSRCS += test-tcp-connect-error-after-write.c
CSRCS += test-tcp-connect-error.c
CSRCS += test-tcp-connect-timeout.c
CSRCS += test-tcp-create-socket-early.c
CSRCS += test-tcp-flags.c
CSRCS += test-tcp-oob.c
CSRCS += test-tcp-open.c
CSRCS += test-tcp-read-stop.c
CSRCS += test-tcp-read-stop-start.c
CSRCS += test-tcp-shutdown-after-write.c
CSRCS += test-tcp-try-write.c
CSRCS += test-tcp-try-write-error.c
CSRCS += test-tcp-unexpected-read.c
CSRCS += test-tcp-write-after-connect.c
CSRCS += test-tcp-writealot.c
CSRCS += test-tcp-write-fail.c
CSRCS += test-tcp-write-queue-order.c
CSRCS += test-tcp-write-to-half-open-connection.c
CSRCS += test-test-macros.c
CSRCS += test-thread.c
CSRCS += test-thread-equal.c
CSRCS += test-threadpool.c
CSRCS += test-threadpool-cancel.c
CSRCS += test-timer-again.c
CSRCS += test-timer.c
CSRCS += test-timer-from-check.c
CSRCS += test-tmpdir.c
CSRCS += test-tty.c
CSRCS += test-tty-duplicate-key.c
CSRCS += test-tty-escape-sequence-processing.c
CSRCS += test-udp-alloc-cb-fail.c
CSRCS += test-udp-bind.c
CSRCS += test-udp-connect.c
CSRCS += test-udp-create-socket-early.c
CSRCS += test-udp-dgram-too-big.c
CSRCS += test-udp-ipv6.c
CSRCS += test-udp-mmsg.c
CSRCS += test-udp-multicast-interface6.c
CSRCS += test-udp-multicast-interface.c
CSRCS += test-udp-multicast-join6.c
CSRCS += test-udp-multicast-join.c
CSRCS += test-udp-multicast-ttl.c
CSRCS += test-udp-open.c
CSRCS += test-udp-options.c
CSRCS += test-udp-send-and-recv.c
CSRCS += test-udp-send-hang-loop.c
CSRCS += test-udp-send-immediate.c
CSRCS += test-udp-sendmmsg-error.c
CSRCS += test-udp-send-unreachable.c
CSRCS += test-udp-try-send.c
CSRCS += test-uname.c
CSRCS += test-walk-handles.c
CSRCS += test-watcher-cross-stop.c
endif
ifneq ($(CONFIG_LIBUV_UTILS_BENCHMARK),)
PROGNAME = uv_run_benchmarks
MAINSRC = run-benchmarks.c
CSRCS += runner.c
CSRCS += runner-unix.c
CSRCS += benchmark-async-pummel.c
CSRCS += benchmark-async.c
CSRCS += benchmark-fs-stat.c
CSRCS += benchmark-getaddrinfo.c
CSRCS += benchmark-loop-count.c
CSRCS += benchmark-million-async.c
CSRCS += benchmark-million-timers.c
CSRCS += benchmark-multi-accept.c
CSRCS += benchmark-ping-pongs.c
CSRCS += benchmark-ping-udp.c
CSRCS += benchmark-pound.c
CSRCS += benchmark-pump.c
CSRCS += benchmark-sizes.c
CSRCS += benchmark-spawn.c
CSRCS += benchmark-tcp-write-batch.c
CSRCS += benchmark-thread.c
CSRCS += benchmark-udp-pummel.c
CSRCS += blackhole-server.c
CSRCS += echo-server.c
endif
context:: $(LIBUV_UNPACK)/.patch
distclean::
$(call DELDIR, $(LIBUV_UNPACK))
$(call DELFILE, $(LIBUV_TARBALL))
include $(APPDIR)/Application.mk

17
system/libuv/README.md Normal file
View File

@ -0,0 +1,17 @@
# `libuv`
Most features of libuv are supported by current port, except SIGPROF relative function (loop_configure).
Nearly full libuv's test suite avaliable on NuttX, but some known case can't run on sim:
* loop_update_time
* idle_starvation
* signal_multiple_loops
* signal_pending_on_close
* metrics_idle_time
* metrics_idle_time_thread
* metrics_idle_time_zero
And some will cause crash by some reason:
* fs_poll_ref

View File

@ -1,129 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config LIBUV
bool "libuv asynchronous I/O Library"
default n
---help---
Enable build for libuv asynchronous I/O Library
if LIBUV
config LIBUV_NPOLLWAITERS
int "Number of uv loop poll waiters"
default 8
---help---
Maximum number of events a loop can wait on.
config LIBUV_ASYNC
bool "libuv async support"
default n
select EVENT_FD
select EVENT_FD_POLL
---help---
Enable async support in libuv.
Eventfd is required for this feature.
config LIBUV_TIMER
bool "libuv software timers support"
default n
---help---
Enable software timers support in libuv.
config LIBUV_TIMER_NUTTX
bool "optimized software timers"
default y
depends on LIBUV_TIMER
---help---
Replace default libuv timer with optimized implementation
with low memory footprint.
config LIBUV_STREAM
bool "libuv stream support"
default n
---help---
Enable stream support in libuv.
config LIBUV_STREAM_READ_SIZE
int "Stream read buffer size"
default 128
depends on LIBUV_STREAM
---help---
Defines the size of buffer used for stream reads.
config LIBUV_PIPE
bool "libuv pipe support"
default n
depends on LIBUV_STREAM
---help---
Enable libuv pipe support.
config LIBUV_FS
bool "libuv FS support"
default n
---help---
Enable libuv FS support.
This feature may require LIBUV_WQ to support async FS operations.
config LIBUV_FS_POLL
bool "libuv fs-poll support"
default n
select LIBUV_FS
select LIBUV_TIMER
---help---
Enable libuv uv_fs_poll_*() API.
config LIBUV_NET
bool
config LIBUV_TCP
bool "libuv TCP support"
default n
depends on NET_TCP
depends on NET_TCPBACKLOG
select LIBUV_STREAM
select LIBUV_NET
---help---
Enable TCP support in libuv.
NET_TCPBACKLOG is required to poll on accept().
config LIBUV_WQ
bool "libuv workqueue support"
default n
select LIBUV_ASYNC
---help---
Enable workqueue support in libuv
config LIBUV_WQ_THREADS_COUNT
int "libuv workqueue thread count"
depends on LIBUV_WQ
default 1
---help---
Specify worker thread count shared between all uv loops
config LIBUV_LOOP_WATCHERS
bool "libuv loop watchers support"
default n
---help---
Enable loop watchers support in libuv (idle,prepare and check)
config LIBUV_CONTEXT
bool "Use static context for loops"
default y
---help---
Modify libuv API to remove static memory usage.
User must call "uv_context_init()" before any other libuv API and
must call "uv_library_shutdown()" when done.
This is required for flat memory builds else some libuv structures
will be shared between processes which can lead to inconsistency.
This option disable support for uv_default_loop() API.
config LIBUV_LOW_FOOTPRINT
bool "Reduce libuv memory usage"
default y
---help---
Enable optimizations to reduce libuv memory usage
endif # LIBUV

View File

@ -1,31 +0,0 @@
############################################################################
# apps/system/libuv/libuv/Make.defs
#
# 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.
#
############################################################################
ifneq ($(CONFIG_LIBUV),)
CONFIGURED_APPS += $(APPDIR)/system/libuv/libuv
# Enable <uv.h> include.
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" \
$(APPDIR)/system/libuv/$(LIBUV_UNPACKNAME)/include}
CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" \
$(APPDIR)/system/libuv/$(LIBUV_UNPACKNAME)/include}
endif

View File

@ -1,124 +0,0 @@
############################################################################
# apps/system/libuv/Makefile
#
# 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.
#
############################################################################
include $(APPDIR)/Make.defs
LIBUV_PATCHS ?= $(sort $(wildcard $(LIBUV_DIR)/000*.patch))
UNPACK ?= unzip -q
$(LIBUV_DIR)/$(CONFIG_LIBUV_TARBALL):
@echo "Downloading: $(CONFIG_LIBUV_TARBALL)"
$(Q) curl -L $(CONFIG_LIBUV_URL)/$(CONFIG_LIBUV_TARBALL) \
-o $(LIBUV_DIR)/$(CONFIG_LIBUV_TARBALL)
$(LIBUV_UNPACKDIR): $(LIBUV_DIR)/$(CONFIG_LIBUV_TARBALL)
@echo "Unpacking: $(CONFIG_LIBUV_TARBALL) -> $(LIBUV_UNPACKDIR)"
$(call DELDIR, $(LIBUV_UNPACKDIR))
$(Q) unzip -q -d "$(LIBUV_DIR)" "$(LIBUV_DIR)/$(CONFIG_LIBUV_TARBALL)"
$(Q) cat $(LIBUV_PATCHS) | \
patch -s -N -d $(LIBUV_UNPACKDIR) -p1
$(Q) touch $(LIBUV_UNPACKDIR)
# Build libuv library
CFLAGS += -I$(LIBUV_UNPACKDIR)/src
CFLAGS += -I$(LIBUV_UNPACKDIR)/src/unix
CFLAGS += -D__NUTTX__
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/core.c
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/poll.c
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/loop.c
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/thread.c
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/no-proctitle.c
ifeq ($(CONFIG_DEV_URANDOM),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/random-devurandom.c
CSRCS += $(LIBUV_UNPACKDIR)/src/random.c
endif
ifeq ($(CONFIG_LIBUV_LOOP_WATCHERS),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/loop-watcher.c
endif
# FIXME signal does not work yet
ifeq ($(CONFIG_LIBUV_SIGNAL),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/signal.c
endif
# FIXME process does not work yet
ifeq ($(CONFIG_LIBUV_PROCESS),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/process.c
endif
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/nuttx.c
ifeq ($(CONFIG_LIBUV_STREAM),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/nuttx_stream.c
endif
ifeq ($(CONFIG_LIBUV_TCP),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/nuttx_tcp.c
endif
ifeq ($(CONFIG_LIBUV_WQ),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/nuttx_threadpool.c
endif
ifeq ($(CONFIG_LIBUV_ASYNC),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/async.c
endif
ifeq ($(CONFIG_LIBUV_PIPE),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/pipe.c
endif
ifeq ($(CONFIG_LIBUV_FS),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/fs.c
endif
ifeq ($(CONFIG_LIBUV_FS_POLL),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/fs-poll.c
endif
ifeq ($(CONFIG_LIBUV_TIMER),y)
ifeq ($(CONFIG_LIBUV_TIMER_NUTTX),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/unix/nuttx_timer.c
else
CSRCS += $(LIBUV_UNPACKDIR)/src/timer.c
endif
endif
CSRCS += $(LIBUV_UNPACKDIR)/src/uv-common.c
CSRCS += $(LIBUV_UNPACKDIR)/src/strscpy.c
ifeq ($(CONFIG_LIBUV_NET),y)
CSRCS += $(LIBUV_UNPACKDIR)/src/inet.c
endif
context:: $(LIBUV_UNPACKDIR)
clean::
$(call DELFILE, $(OBJS))
distclean::
$(call DELDIR, $(LIBUV_UNPACKDIR))
$(call DELFILE, $(LIBUV_DIR)/$(CONFIG_LIBUV_TARBALL))
include $(APPDIR)/Application.mk

View File

@ -1,35 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig LIBUV_UNIT_TESTS
tristate "libuv unit-tests command"
default n
depends on LIBUV
select LIBUV_TIMER
select LIBUV_ASYNC
select LIBUV_WQ
select LIBUV_LOOP_WATCHERS
select LIBUV_CONTEXT
---help---
Add executable that runs all libuv unit-tests.
if LIBUV_UNIT_TESTS
config LIBUV_UNIT_TESTS_PROGNAME
string "libuv unit-tests program name"
default "libuvtest"
---help---
This is the name of the program that will be used when the NSH ELF
program is installed.
config LIBUV_UNIT_TESTS_PRIORITY
int "libuv unit-tests task priority"
default 100
config LIBUV_UNIT_TESTS_STACKSIZE
int "libuv unit-tests stack size"
default DEFAULT_TASK_STACKSIZE
endif # LIBUV_UNIT_TESTS

View File

@ -1,23 +0,0 @@
############################################################################
# apps/system/libuv/tests/Make.defs
#
# 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.
#
############################################################################
ifneq ($(CONFIG_LIBUV_UNIT_TESTS),)
CONFIGURED_APPS += $(APPDIR)/system/libuv/tests
endif

View File

@ -1,72 +0,0 @@
############################################################################
# apps/system/libuv/tests/Makefile
#
# 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.
#
############################################################################
include $(APPDIR)/Make.defs
# libuv unit-tests command
PROGNAME := $(CONFIG_LIBUV_UNIT_TESTS_PROGNAME)
PRIORITY := $(CONFIG_LIBUV_UNIT_TESTS_PRIORITY)
STACKSIZE := $(CONFIG_LIBUV_UNIT_TESTS_STACKSIZE)
MODULE := $(CONFIG_LIBUV_UNIT_TESTS)
# Files
MAINSRC := test_main.c
CSRCS += runner-nuttx.c
CSRCS += $(LIBUV_UNPACKDIR)/test/runner.c
# Tests
CSRCS += $(LIBUV_UNPACKDIR)/test/test-loop-time.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-async.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-ip4-addr.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-active.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-idle.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-timer.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-timer-from-check.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-timer-again.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-threadpool.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-walk-handles.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-poll-close.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-loop-close.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-loop-stop.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-tcp-read-stop.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-ping-pong.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-tcp-write-after-connect.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-fs-copyfile.c
CSRCS += $(LIBUV_UNPACKDIR)/test/test-fs-poll.c
ifeq ($(CONFIG_DEV_URANDOM),y)
CSRCS += $(LIBUV_UNPACKDIR)/test/test-random.c
endif
# Test helpers
CSRCS += $(LIBUV_UNPACKDIR)/test/echo-server.c
# Compilation flags
CFLAGS += -I$(LIBUV_UNPACKDIR)/test
CFLAGS += -I.
CFLAGS += -D__NUTTX__
clean::
$(call DELFILE, $(OBJS))
include $(APPDIR)/Application.mk

View File

@ -1,152 +0,0 @@
/****************************************************************************
* apps/system/libuv/tests/runner-nuttx.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <debug.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <uv.h>
#include "runner-nuttx.h"
#include "runner.h"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static uint32_t get_time_ms(void);
static void *process_launcher(void *arg);
/****************************************************************************
* Private Functions
****************************************************************************/
static uint32_t get_time_ms(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint32_t)(((uint64_t) ts.tv_sec) * 1000 +
(ts.tv_nsec / 1000 / 1000));
}
static void *process_launcher(void *arg)
{
process_info_t *p = (process_info_t *)arg;
p->task->main();
sem_post(&p->sem);
return NULL;
}
/****************************************************************************
* Public Functions
****************************************************************************/
void platform_init(int argc, char **argv)
{
}
int process_start(task_entry_t *task, process_info_t *p, int is_helper)
{
if (is_helper)
{
printf("===> START HELPER %s/%s\n",
task->task_name, task->process_name);
}
else
{
printf("===> START TEST %s\n", task->task_name);
}
p->task = task;
if (sem_init(&p->sem, 0, 0))
{
return -1;
}
if (pthread_create(&p->tid, NULL, process_launcher, p) != 0)
{
fprintf(stderr, "Failed to start process %s\n", task->process_name);
sem_destroy(&p->sem);
return -1;
}
return 0;
}
int process_wait(process_info_t *vec, int n, int timeout)
{
uv_time_t time = get_time_ms();
while (--n >= 0)
{
int found = 0;
while ((uv_time_t)(get_time_ms()-time) < (uv_time_t)timeout)
{
if (sem_trywait(&vec[n].sem) == 0)
{
FAR pthread_addr_t value;
pthread_join(vec[n].tid, &value);
found = 1;
break;
}
if (errno != EAGAIN)
{
break;
}
/* Let NuttX update time */
usleep(100 * 1000);
}
if (!found)
{
/* Timeout or error */
return -1;
}
}
return 0;
}
int process_terminate(process_info_t *p)
{
/* TODO */
return 0;
}
int process_reap(process_info_t *p)
{
/* TODO */
return 0;
}
void process_cleanup(process_info_t *p)
{
}

View File

@ -1,46 +0,0 @@
/****************************************************************************
* apps/system/libuv/tests/runner-nuttx.h
*
* 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.
*
****************************************************************************/
#ifndef TEST_RUNNER_NUTTX_H
#define TEST_RUNNER_NUTTX_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <pthread.h>
#include <stdio.h>
/****************************************************************************
* Public Type Declarations
****************************************************************************/
struct task_entry_s;
struct process_info_s
{
pthread_t tid;
sem_t sem;
struct task_entry_s *task;
};
typedef struct process_info_s process_info_t;
#endif /* TEST_RUNNER_NUTTX_H */

View File

@ -1,56 +0,0 @@
/****************************************************************************
* apps/system/libuv/tests/test_main.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <string.h>
#include "runner.h"
#include "test-list.h"
/****************************************************************************
* Public Functions
****************************************************************************/
int main(int argc, FAR char **argv)
{
platform_init(argc, argv);
if (argc > 1)
{
if (strcmp(argv[1], "--list") == 0)
{
print_tests(stdout);
return 0;
}
if (argc > 2)
{
return run_test_part(argv[1], argv[2]);
}
}
return run_tests(0);
}