1
0
forked from cory/tildefriends
Files
apps
core
deps
codemirror
crypt_blowfish
libbacktrace
libbacktrace_config
libsodium
libuv
.github
docs
img
include
m4
src
test
fixtures
benchmark-async-pummel.c
benchmark-async.c
benchmark-fs-stat.c
benchmark-getaddrinfo.c
benchmark-list.h
benchmark-loop-count.c
benchmark-million-async.c
benchmark-million-timers.c
benchmark-multi-accept.c
benchmark-ping-pongs.c
benchmark-ping-udp.c
benchmark-pound.c
benchmark-pump.c
benchmark-queue-work.c
benchmark-sizes.c
benchmark-spawn.c
benchmark-tcp-write-batch.c
benchmark-thread.c
benchmark-udp-pummel.c
blackhole-server.c
echo-server.c
run-benchmarks.c
run-tests.c
runner-unix.c
runner-unix.h
runner-win.c
runner-win.h
runner.c
runner.h
task.h
test-active.c
test-async-null-cb.c
test-async.c
test-barrier.c
test-callback-stack.c
test-close-fd.c
test-close-order.c
test-condvar.c
test-connect-unspecified.c
test-connection-fail.c
test-cwd-and-chdir.c
test-default-loop-close.c
test-delayed-accept.c
test-dlerror.c
test-eintr-handling.c
test-embed.c
test-emfile.c
test-env-vars.c
test-error.c
test-fail-always.c
test-fork.c
test-fs-copyfile.c
test-fs-event.c
test-fs-fd-hash.c
test-fs-open-flags.c
test-fs-poll.c
test-fs-readdir.c
test-fs.c
test-get-currentexe.c
test-get-loadavg.c
test-get-memory.c
test-get-passwd.c
test-getaddrinfo.c
test-gethostname.c
test-getnameinfo.c
test-getsockname.c
test-getters-setters.c
test-gettimeofday.c
test-handle-fileno.c
test-homedir.c
test-hrtime.c
test-idle.c
test-idna.c
test-ip-name.c
test-ip4-addr.c
test-ip6-addr.c
test-ipc-heavy-traffic-deadlock-bug.c
test-ipc-send-recv.c
test-ipc.c
test-list.h
test-loop-alive.c
test-loop-close.c
test-loop-configure.c
test-loop-handles.c
test-loop-stop.c
test-loop-time.c
test-metrics.c
test-multiple-listen.c
test-mutexes.c
test-not-readable-nor-writable-on-read-error.c
test-not-writable-after-shutdown.c
test-osx-select.c
test-pass-always.c
test-ping-pong.c
test-pipe-bind-error.c
test-pipe-close-stdout-read-stdin.c
test-pipe-connect-error.c
test-pipe-connect-multiple.c
test-pipe-connect-prepare.c
test-pipe-getsockname.c
test-pipe-pending-instances.c
test-pipe-sendmsg.c
test-pipe-server-close.c
test-pipe-set-fchmod.c
test-pipe-set-non-blocking.c
test-platform-output.c
test-poll-close-doesnt-corrupt-stack.c
test-poll-close.c
test-poll-closesocket.c
test-poll-multiple-handles.c
test-poll-oob.c
test-poll.c
test-process-priority.c
test-process-title-threadsafe.c
test-process-title.c
test-queue-foreach-delete.c
test-random.c
test-readable-on-eof.c
test-ref.c
test-run-nowait.c
test-run-once.c
test-semaphore.c
test-shutdown-close.c
test-shutdown-eof.c
test-shutdown-simultaneous.c
test-shutdown-twice.c
test-signal-multiple-loops.c
test-signal-pending-on-close.c
test-signal.c
test-socket-buffer-size.c
test-spawn.c
test-stdio-over-pipes.c
test-strscpy.c
test-strtok.c
test-tcp-alloc-cb-fail.c
test-tcp-bind-error.c
test-tcp-bind6-error.c
test-tcp-close-accept.c
test-tcp-close-after-read-timeout.c
test-tcp-close-reset.c
test-tcp-close-while-connecting.c
test-tcp-close.c
test-tcp-connect-error-after-write.c
test-tcp-connect-error.c
test-tcp-connect-timeout.c
test-tcp-connect6-error.c
test-tcp-create-socket-early.c
test-tcp-flags.c
test-tcp-oob.c
test-tcp-open.c
test-tcp-read-stop-start.c
test-tcp-read-stop.c
test-tcp-rst.c
test-tcp-shutdown-after-write.c
test-tcp-try-write-error.c
test-tcp-try-write.c
test-tcp-unexpected-read.c
test-tcp-write-after-connect.c
test-tcp-write-fail.c
test-tcp-write-queue-order.c
test-tcp-write-to-half-open-connection.c
test-tcp-writealot.c
test-test-macros.c
test-thread-equal.c
test-thread.c
test-threadpool-cancel.c
test-threadpool.c
test-timer-again.c
test-timer-from-check.c
test-timer.c
test-tmpdir.c
test-tty-duplicate-key.c
test-tty-escape-sequence-processing.c
test-tty.c
test-udp-alloc-cb-fail.c
test-udp-bind.c
test-udp-connect.c
test-udp-connect6.c
test-udp-create-socket-early.c
test-udp-dgram-too-big.c
test-udp-ipv6.c
test-udp-mmsg.c
test-udp-multicast-interface.c
test-udp-multicast-interface6.c
test-udp-multicast-join.c
test-udp-multicast-join6.c
test-udp-multicast-ttl.c
test-udp-open.c
test-udp-options.c
test-udp-send-and-recv.c
test-udp-send-hang-loop.c
test-udp-send-immediate.c
test-udp-send-unreachable.c
test-udp-sendmmsg-error.c
test-udp-try-send.c
test-uname.c
test-walk-handles.c
test-watcher-cross-stop.c
tools
.gitattributes
.gitignore
.mailmap
.readthedocs.yaml
AUTHORS
CMakeLists.txt
CONTRIBUTING.md
ChangeLog
LICENSE
LICENSE-docs
LINKS.md
MAINTAINERS.md
Makefile.am
README.md
SUPPORTED_PLATFORMS.md
autogen.sh
configure.ac
libuv-static.pc.in
libuv.pc.in
uv_win_longpath.manifest
openssl
picohttpparser
quickjs
smoothie
speedscope
split
sqlite
valgrind
xopt
docs
src
tools
.dockerignore
Dockerfile
LICENSE
Makefile
README.md
tildefriends/deps/libuv/test/runner.h

173 lines
5.2 KiB
C
Raw Normal View History

/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef RUNNER_H_
#define RUNNER_H_
#include <limits.h> /* PATH_MAX */
#include <stdio.h> /* FILE */
/*
* The maximum number of processes (main + helpers) that a test / benchmark
* can have.
*/
#define MAX_PROCESSES 8
/*
* Struct to store both tests and to define helper processes for tasks.
*/
typedef struct {
char *task_name;
char *process_name;
int (*main)(void);
int is_helper;
int show_output;
/*
* The time in milliseconds after which a single test or benchmark times out.
*/
int timeout;
} task_entry_t, bench_entry_t;
/*
* Macros used by test-list.h and benchmark-list.h.
*/
#define TASK_LIST_START \
task_entry_t TASKS[] = {
#define TASK_LIST_END \
{ 0, 0, 0, 0, 0, 0 } \
};
#define TEST_DECLARE(name) \
int run_test_##name(void);
#define TEST_ENTRY(name) \
{ #name, #name, &run_test_##name, 0, 0, 5000 },
#define TEST_ENTRY_CUSTOM(name, is_helper, show_output, timeout) \
{ #name, #name, &run_test_##name, is_helper, show_output, timeout },
#define BENCHMARK_DECLARE(name) \
int run_benchmark_##name(void);
#define BENCHMARK_ENTRY(name) \
{ #name, #name, &run_benchmark_##name, 0, 0, 60000 },
#define HELPER_DECLARE(name) \
int run_helper_##name(void);
#define HELPER_ENTRY(task_name, name) \
{ #task_name, #name, &run_helper_##name, 1, 0, 0 },
#define TEST_HELPER HELPER_ENTRY
#define BENCHMARK_HELPER HELPER_ENTRY
extern char executable_path[4096];
/*
* Include platform-dependent definitions
*/
#ifdef _WIN32
# include "runner-win.h"
#else
# include "runner-unix.h"
#endif
/* The array that is filled by test-list.h or benchmark-list.h */
extern task_entry_t TASKS[];
/*
* Run all tests.
*/
int run_tests(int benchmark_output);
/*
* Run a single test. Starts up any helpers.
*/
int run_test(const char* test,
int benchmark_output,
int test_count);
/*
* Run a test part, i.e. the test or one of its helpers.
*/
int run_test_part(const char* test, const char* part);
/*
* Print tests in sorted order to `stream`. Used by `./run-tests --list`.
*/
void print_tests(FILE* stream);
/* Print lines in |buffer| as TAP diagnostics to |stream|. */
void print_lines(const char* buffer, size_t size, FILE* stream);
/*
* Stuff that should be implemented by test-runner-<platform>.h
* All functions return 0 on success, -1 on failure, unless specified
* otherwise.
*/
/* Do platform-specific initialization. */
void platform_init(int argc, char** argv);
/* Invoke "argv[0] test-name [test-part]". Store process info in *p. Make sure
* that all stdio output of the processes is buffered up. */
int process_start(char *name, char* part, process_info_t *p, int is_helper);
/* Wait for all `n` processes in `vec` to terminate. Time out after `timeout`
* msec, or never if timeout == -1. Return 0 if all processes are terminated,
* -1 on error, -2 on timeout. */
int process_wait(process_info_t *vec, int n, int timeout);
/* Returns the number of bytes in the stdio output buffer for process `p`. */
long int process_output_size(process_info_t *p);
/* Copy the contents of the stdio output buffer to `stream`. */
int process_copy_output(process_info_t* p, FILE* stream);
/* Copy the last line of the stdio output buffer to `buffer` */
int process_read_last_line(process_info_t *p,
char * buffer,
size_t buffer_len);
/* Return the name that was specified when `p` was started by process_start */
char* process_get_name(process_info_t *p);
/* Terminate process `p`. */
int process_terminate(process_info_t *p);
/* Return the exit code of process p. On error, return -1. */
int process_reap(process_info_t *p);
/* Clean up after terminating process `p` (e.g. free the output buffer etc.). */
void process_cleanup(process_info_t *p);
/* Move the console cursor one line up and back to the first column. */
void rewind_cursor(void);
#endif /* RUNNER_H_ */