![]() |
botsense
3.2.0
RoadNarrows Client-Server Proxied Services Framework
|
BotSense bsProxy server load tester client(s). More...
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <libgen.h>
#include <pthread.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include "rnr/rnrconfig.h"
#include "rnr/new.h"
#include "rnr/opts.h"
#include "rnr/log.h"
#include "botsense/BotSense.h"
#include "botsense/libBotSense.h"
#include "botsense/bsProxyMsgs.h"
#include "botsense/bsI2C.h"
#include "botsense/bsI2CMsgs.h"
#include "botsense/bsNull.h"
#include "botsense/bsNullMsgs.h"
#include "botsense/bsSerial.h"
#include "botsense/bsSerialMsgs.h"
#include "version.h"
Go to the source code of this file.
Macros | |
#define | APP_EC_OK 0 |
success exit code | |
#define | APP_EC_USAGE 2 |
usage error exit code | |
#define | APP_EC_EXEC 4 |
execution error exit code | |
#define | LT_MAX_CLIENTS 256 |
maximum number of load testing clients | |
#define | LT_MAX_VCONN 4 |
maximum number of virtual conn. / client | |
#define | LT_N_CLIENT_DFT 1 |
default option load testing client count | |
#define | LT_DEVICES_DFT "server,null" |
default option list of proxied devices | |
#define | LT_DEV_SERVER 0x0001 |
load test server-terminated requests | |
#define | LT_DEV_I2C 0x0002 |
load test proxied I2C device requests | |
#define | LT_DEV_NULL 0x0004 |
load test proxied /dev/null requests | |
#define | LT_DEV_SERIAL 0x0008 |
load test proxied serial device requests | |
#define | LT_T_MIN 1000 |
minimum thread sleep time | |
#define | LT_T_MAX 2000000 |
minimum thread sleep time | |
Functions | |
static int | OptsCvtArgServerAddr (const char *argv0, const char *sOptName, char *optarg, void *pOptVal) |
Convert command-line server option IP address string to network name/number and port number. More... | |
static int | OptsCvtArgClientCnt (const char *argv0, const char *sOptName, char *optarg, void *pOptVal) |
Convert command-line client count option. More... | |
static int | OptsCvtArgDevices (const char *argv0, const char *sOptName, char *optarg, void *pOptVal) |
Convert command-line devices option string to bitmap. More... | |
static void | RandSeed () |
Seed random number generator. | |
static uint_t | RandN (uint_t n) |
Generate random integer between [0,n). More... | |
static void | RandSleep (uint_t tmin, uint_t tmax) |
Sleep for a random μs duration between [tmin, tmax]. More... | |
static BsVConnHnd_T | RandVConn (BsVecHandles_T *pVConnList) |
Randomly pick a virtual connection in list. More... | |
static void * | LtThreadI2C (void *pArg) |
Load test proxied I2C device thread. More... | |
static void | ClientStartTestThreadI2C (BsClient_P pClient) |
Start proxied I2C device load test thread. More... | |
static void * | LtThreadNull (void *pArg) |
Load test proxied /dev/null device thread. More... | |
static void | ClientStartTestThreadNull (BsClient_P pClient) |
Start proxied /dev/null device load test thread. More... | |
static void * | LtThreadSerial (void *pArg) |
Load test proxied serial device thread. More... | |
static void | ClientStartTestThreadSerial (BsClient_P pClient) |
Start proxied serial device load test thread. More... | |
static void * | LtThreadServer (void *pArg) |
Load test server-terminated messages thread. More... | |
static void | ClientStartTestThreadServer (BsClient_P pClient) |
Start server-terminated requests load test thread. More... | |
static BsClient_P | CreateTestClient (int i) |
Get and pretty print all the versions from all proxied entities. More... | |
static int | MainInit (int argc, char *argv[]) |
Initialize application. More... | |
int | main (int argc, char *argv[]) |
Application main. More... | |
Variables | |
static char * | Argv0 |
this command basename | |
static char * | OptsProxyServer = "localhost" |
proxy server addr/port | |
static int | OptsClientCnt = 1 |
number of clients | |
static char * | OptsDevices = "server,null" |
number of clients | |
static bool_t | OptsFixedDiag = false |
fixed diagnostics | |
static char * | OptsDevSerial = "/dev/ttyS0" |
serial device | |
static char * | OptsDevI2C = "/dev/i2c-0" |
i2c device | |
static OptsPgmInfo_T | PgmInfo |
Program information. More... | |
static OptsInfo_T | OptsInfo [] |
Command-line options information. | |
static char * | ProxyIPAddr = "localhost" |
default bsProxy IP addr | |
static int | ProxyIPPort = BSPROXY_LISTEN_PORT_DFT |
default bsProxy port | |
static BsClient_P | Client [256] |
array of clients | |
static uint_t | ProxiedDevices |
proxied devices More... | |
union { | |
ulong_t seed | |
the initial seed | |
ushort_t xsubi [3] | |
successive x_i'th 48-bit value | |
} | RandomSeq |
Random seed. | |
BotSense bsProxy server load tester client(s).
Definition in file bsLoadTest.c.
|
static |
Start proxied I2C device load test thread.
pClient | BotSense client. |
Definition at line 429 of file bsLoadTest.c.
References BS_ECODE_NO_EXEC, BSCLIENT_LOG_SYSERROR, and LtThreadI2C().
Referenced by CreateTestClient().
|
static |
Start proxied /dev/null device load test thread.
pClient | BotSense client. |
Definition at line 568 of file bsLoadTest.c.
References BS_ECODE_NO_EXEC, BSCLIENT_LOG_SYSERROR, and LtThreadNull().
Referenced by CreateTestClient().
|
static |
Start proxied serial device load test thread.
pClient | BotSense client. |
Definition at line 714 of file bsLoadTest.c.
References BS_ECODE_NO_EXEC, BSCLIENT_LOG_SYSERROR, and LtThreadSerial().
Referenced by CreateTestClient().
|
static |
Start server-terminated requests load test thread.
pClient | BotSense client. |
Definition at line 896 of file bsLoadTest.c.
References BS_ECODE_NO_EXEC, BSCLIENT_LOG_SYSERROR, and LtThreadServer().
Referenced by CreateTestClient().
|
static |
Get and pretty print all the versions from all proxied entities.
The returned BotSense allocatated string is multi-lined.
i | Test client instance. |
Definition at line 915 of file bsLoadTest.c.
References BS_OK, ClientStartTestThreadI2C(), ClientStartTestThreadNull(), ClientStartTestThreadSerial(), ClientStartTestThreadServer(), LT_DEV_I2C, LT_DEV_NULL, LT_DEV_SERIAL, LT_DEV_SERVER, ProxiedDevices, ProxyIPAddr, and ProxyIPPort.
Referenced by main().
|
static |
Load test proxied I2C device thread.
pArg | BotSense client (casted as a NULL). |
Definition at line 315 of file bsLoadTest.c.
References BS_OK, BSCLIENT_LOG_ERROR, BsI2CMsgIdNumOf, BsI2CMsgIdReqScan, LT_T_MAX, LT_T_MIN, OptsDevI2C, RandN(), and RandSleep().
Referenced by ClientStartTestThreadI2C().
|
static |
Load test proxied /dev/null device thread.
pArg | BotSense client (casted as a NULL). |
Definition at line 448 of file bsLoadTest.c.
References BS_NULL_DEV_NAME, BS_OK, BSCLIENT_LOG_ERROR, BsNullMsgIdNumOf, BsNullMsgIdReqWrite, LT_T_MAX, LT_T_MIN, RandN(), and RandSleep().
Referenced by ClientStartTestThreadNull().
|
static |
Load test proxied serial device thread.
pArg | BotSense client (casted as a NULL). |
Definition at line 587 of file bsLoadTest.c.
References BS_OK, BSCLIENT_LOG_ERROR, BsSerialMsgIdNumOf, BsSerialMsgIdReqRead, BsSerialMsgIdReqTrans, BsSerialMsgIdReqWrite, LT_T_MAX, LT_T_MIN, OptsDevSerial, RandN(), and RandSleep().
Referenced by ClientStartTestThreadSerial().
|
static |
Load test server-terminated messages thread.
pArg | BotSense client (casted as a NULL). |
Definition at line 733 of file bsLoadTest.c.
References BS_OK, BSPROXY_VCONN_SERVER, BSPROXY_VCONN_UNDEF, BsProxyMsgIdReqGetVConnInfo, BsProxyMsgIdReqGetVConnList, BsProxyMsgIdReqGetVersion, BsProxyMsgIdReqLoopback, BsProxyMsgIdReqMsgTrace, BsProxyMsgIdReqSetLogging, LT_MAX_VCONN, LT_T_MAX, LT_T_MIN, BsVConnInfo_T::m_client, BsVConnInfo_T::m_devuri, BsVConnInfo_T::m_moddate, BsVConnInfo_T::m_moduri, BsVConnInfo_T::m_modver, BsVConnInfo_T::m_rd, BsVecHandles_T::m_uCount, BsVConnInfo_T::m_vconn, BsVecHandles_T::m_vecHnd, OptsFixedDiag, RandN(), RandSleep(), and RandVConn().
Referenced by ClientStartTestThreadServer().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Application main.
argc | Command-line argument count. |
argv | Command-line argument list. |
Definition at line 1142 of file bsLoadTest.c.
References APP_EC_OK, CreateTestClient(), MainInit(), and OptsClientCnt.
|
static |
Initialize application.
Any command-line error immediately terminates application.
argc | Command-line argument count. |
argv | Command-line argument list. |
Definition at line 1117 of file bsLoadTest.c.
References APP_EC_OK, Argv0, OptsInfo, PgmInfo, PkgInfo, and RandSeed().
Referenced by main().
|
static |
Convert command-line client count option.
argv0 | Command name. | |
sOptName | Option name. | |
optarg | Parsed option argument to convert (optional). | |
[out] | pOptVal | Pointer to converted option value (not used). |
OptsInvalid() |
Definition at line 1036 of file bsLoadTest.c.
References Argv0, BS_OK, LT_MAX_CLIENTS, and OptsClientCnt.
|
static |
Convert command-line devices option string to bitmap.
argv0 | Command name. | |
sOptName | Option name. | |
optarg | Parsed option argument to convert (optional). | |
[out] | pOptVal | Pointer to converted option value (not used). |
Definition at line 1064 of file bsLoadTest.c.
References Argv0, BS_OK, LT_DEV_I2C, LT_DEV_NULL, LT_DEV_SERIAL, LT_DEV_SERVER, and ProxiedDevices.
|
static |
Convert command-line server option IP address string to network name/number and port number.
argv0 | Command name. | |
sOptName | Option name. | |
optarg | Parsed option argument to convert (optional). | |
[out] | pOptVal | Pointer to converted option value (not used). |
OptsInvalid() |
Definition at line 986 of file bsLoadTest.c.
References Argv0, BS_OK, BSPROXY_LISTEN_PORT_DFT, ProxyIPAddr, and ProxyIPPort.
|
static |
Generate random integer between [0,n).
n | Upper value. |
Definition at line 269 of file bsLoadTest.c.
References RandomSeq.
Referenced by LtThreadI2C(), LtThreadNull(), LtThreadSerial(), LtThreadServer(), RandSleep(), and RandVConn().
|
static |
Sleep for a random μs duration between [tmin, tmax].
tmin | Minimum sleep value. |
tmax | Maximum sleep value. |
Definition at line 284 of file bsLoadTest.c.
References RandN().
Referenced by LtThreadI2C(), LtThreadNull(), LtThreadSerial(), and LtThreadServer().
|
static |
Randomly pick a virtual connection in list.
pVConnList | Virtual connection list. |
Definition at line 296 of file bsLoadTest.c.
References BSPROXY_VCONN_UNDEF, BsVecHandles_T::m_uCount, BsVecHandles_T::m_vecHnd, and RandN().
Referenced by LtThreadServer().
|
static |
Program information.
Definition at line 127 of file bsLoadTest.c.
Referenced by MainInit().
|
static |
proxied devices
Definition at line 240 of file bsLoadTest.c.
Referenced by CreateTestClient(), and OptsCvtArgDevices().