This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-libzt/TESTING.md

84 lines
2.9 KiB
Markdown
Raw Normal View History

## Testing (using src/selftest.cpp)
2017-06-05 17:36:47 -07:00
After building the static library, you can run:
2017-06-05 17:18:06 -07:00
2017-06-05 17:36:47 -07:00
- `make tests`
2017-06-05 17:18:06 -07:00
2017-06-05 17:46:49 -07:00
This will output `selftest` to `build/$PLATFORM/`. Using this, you can run the tests below. Note, the following examples assume your testing environment is `linux`, you'll see this in the build output path. If this is not true, change it to `darwin`, or `win` depending on what you're running.
It is probably easiet to add out your `host-1` and `host-2` address, port, and network information to `test/alice.conf` and `test/bob.conf`, this way you can use the selftest shorthand shown below.
2017-06-05 17:18:06 -07:00
2017-06-05 17:36:47 -07:00
Build outputs are as follows:
```
build
|
|--darwin
| |-libzt.a
| |-selftest
|
|--linux
|-libzt.a
|-selftest
```
***
### Simple Tests
2017-06-05 17:46:49 -07:00
Simple tests merely test one aspect of the library. For instance, its role as an IPv4 server, or IPv6 client.
2017-06-05 17:46:49 -07:00
To run a single-test IPv4 client/server test:
2017-06-05 17:46:49 -07:00
- host-1: `./build/linux/selftest zt1 c7cd7c9e1b0f52a2 simple 4 server 10.9.9.40 8787`
- host-2: `./build/linux/selftest zt2 c7cd7c9e1b0f52a2 simple 4 client 10.9.9.40 8787`
To run a multi-message IPv4 client/server test:
2017-06-05 17:46:49 -07:00
- host-1: `./build/linux/selftest zt1 c7cd7c9e1b0f52a2 simple 4 server 10.9.9.40 8787 n_bytes 100 50`
- host-2: `./build/linux/selftest zt2 c7cd7c9e1b0f52a2 simple 4 client 10.9.9.40 8787 n_bytes 100 50`
### Sustained Tests
Sustained tests will test the library's ability to support long-duration connections and data transfers.
2017-06-05 17:46:49 -07:00
- host-1: `./build/linux/selftest sustained test/bob.conf`
- host-2: `./build/linux/selftest sustained test/alice.conf`
### Slam Tests
2017-06-05 17:46:49 -07:00
Slam tests will test the library's ability to handle many repeated API calls or repeated common sequences of API calls that a typical application may make. For instance, it will try to create as many sockets as possible, or try to create a socket, bind to an address, listen, and accept over and over. This is useful for detecting memory leaks and architectural limitations in the stack drivers.
- host-1: `./build/linux/selftest slam test/bob.conf`
- host-2: `./build/linux/selftest slam test/alice.conf`
### Comprehensive Tests
A comprehensive test will test each aspect of the library one time.
2017-06-05 17:46:49 -07:00
- host-1: `./build/linux/selftest comprehensive test/bob.conf`
- host-2: `./build/linux/selftest comprehensive test/alice.conf`
### Random Tests
Makes random API calls with random (or plausible arguments/data) to test for proper error handling
2017-06-05 17:46:49 -07:00
- host-1: `./build/linux/selftest random test/bob.conf`
### Performance Tests
Test's the library's performance characteristics
2017-06-05 17:46:49 -07:00
- host-1: `./build/linux/selftest performance test/bob.conf`
- host-2: `./build/linux/selftest performance test/alice.conf`
### Correctness Tests
Tests's the library's error handling, address treatment, and blocking/non-blocking behaviour.
2017-06-05 17:46:49 -07:00
- host-1: `./build/linux/selftest correctness test/bob.conf`
- host-2: `./build/linux/selftest correctness test/alice.conf`