MySQL  8.0.17
Source Code Documentation
testapp.c File Reference
#include "config.h"
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include "cache.h"
#include <memcached/util.h>
#include <memcached/protocol_binary.h>
#include <memcached/config_parser.h>

Classes

struct  testcase
 

Macros

#define TMP_TEMPLATE   "/tmp/test_file.XXXXXXX"
 
#define ITERATIONS   1024
 

Typedefs

typedef enum test_return(* TEST_FUNC) (void)
 

Enumerations

enum  test_return { TEST_SKIP, TEST_PASS, TEST_FAIL }
 

Functions

static enum test_return cache_create_test (void)
 
static int cache_constructor (void *buffer, void *notused1, int notused2)
 
static enum test_return cache_constructor_test (void)
 
static int cache_fail_constructor (void *buffer, void *notused1, int notused2)
 
static enum test_return cache_fail_constructor_test (void)
 
static void cache_destructor (void *buffer, void *notused)
 
static enum test_return cache_destructor_test (void)
 
static enum test_return cache_reuse_test (void)
 
static enum test_return cache_bulkalloc (size_t datasize)
 
static enum test_return test_issue_161 (void)
 
static enum test_return cache_redzone_test (void)
 
static enum test_return test_safe_strtoul (void)
 
static enum test_return test_safe_strtoull (void)
 
static enum test_return test_safe_strtoll (void)
 
static enum test_return test_safe_strtol (void)
 
static enum test_return test_safe_strtof (void)
 
static pid_t start_server (in_port_t *port_out, bool daemon, int timeout)
 Function to start the server and let it listen on a random port. More...
 
static enum test_return test_issue_44 (void)
 
static struct addrinfo * lookuphost (const char *hostname, in_port_t port)
 
static int connect_server (const char *hostname, in_port_t port, bool nonblock)
 
static enum test_return test_vperror (void)
 
static char * trim (char *ptr)
 
static enum test_return test_config_parser (void)
 
static void send_ascii_command (const char *buf)
 
static void read_ascii_response (char *buffer, size_t size)
 
static enum test_return test_issue_92 (void)
 
static enum test_return test_issue_102 (void)
 
static enum test_return start_memcached_server (void)
 
static enum test_return stop_memcached_server (void)
 
static void safe_send (const void *buf, size_t len, bool hickup)
 
static bool safe_recv (void *buf, size_t len)
 
static bool safe_recv_packet (void *buf, size_t size)
 
static off_t storage_command (char *buf, size_t bufsz, uint8_t cmd, const void *key, size_t keylen, const void *dta, size_t dtalen, uint32_t flags, uint32_t exp)
 
static off_t raw_command (char *buf, size_t bufsz, uint8_t cmd, const void *key, size_t keylen, const void *dta, size_t dtalen)
 
static off_t flush_command (char *buf, size_t bufsz, uint8_t cmd, uint32_t exptime, bool use_extra)
 
static off_t arithmetic_command (char *buf, size_t bufsz, uint8_t cmd, const void *key, size_t keylen, uint64_t delta, uint64_t initial, uint32_t exp)
 
static void validate_response_header (protocol_binary_response_no_extras *response, uint8_t cmd, uint16_t status)
 
static enum test_return test_binary_noop (void)
 
static enum test_return test_binary_quit_impl (uint8_t cmd)
 
static enum test_return test_binary_quit (void)
 
static enum test_return test_binary_quitq (void)
 
static enum test_return test_binary_set_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_set (void)
 
static enum test_return test_binary_setq (void)
 
static enum test_return test_binary_add_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_add (void)
 
static enum test_return test_binary_addq (void)
 
static enum test_return test_binary_replace_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_replace (void)
 
static enum test_return test_binary_replaceq (void)
 
static enum test_return test_binary_delete_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_delete (void)
 
static enum test_return test_binary_deleteq (void)
 
static enum test_return test_binary_get_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_get (void)
 
static enum test_return test_binary_getk (void)
 
static enum test_return test_binary_getq_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_getq (void)
 
static enum test_return test_binary_getkq (void)
 
static enum test_return test_binary_incr_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_incr (void)
 
static enum test_return test_binary_incrq (void)
 
static enum test_return test_binary_decr_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_decr (void)
 
static enum test_return test_binary_decrq (void)
 
static enum test_return test_binary_version (void)
 
static enum test_return test_binary_flush_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_flush (void)
 
static enum test_return test_binary_flushq (void)
 
static enum test_return test_binary_cas (void)
 
static enum test_return test_binary_concat_impl (const char *key, uint8_t cmd)
 
static enum test_return test_binary_append (void)
 
static enum test_return test_binary_prepend (void)
 
static enum test_return test_binary_appendq (void)
 
static enum test_return test_binary_prependq (void)
 
static enum test_return test_binary_stat (void)
 
static enum test_return test_binary_scrub (void)
 
static void * binary_hickup_recv_verification_thread (void *arg)
 
static enum test_return test_binary_pipeline_hickup_chunk (void *buffer, size_t buffersize)
 
static enum test_return test_binary_pipeline_hickup (void)
 
static enum test_return test_binary_verbosity (void)
 
static enum test_return test_issue_101 (void)
 
int main (int argc, char **argv)
 

Variables

static pid_t server_pid
 
static in_port_t port
 
static int sock
 
static bool allow_closed_read = false
 
const uint64_t constructor_pattern = 0xdeadcafebabebeef
 
static void * destruct_data = 0
 
volatile bool hickup_thread_running
 
struct testcase testcases []
 

Macro Definition Documentation

◆ ITERATIONS

#define ITERATIONS   1024

◆ TMP_TEMPLATE

#define TMP_TEMPLATE   "/tmp/test_file.XXXXXXX"

Typedef Documentation

◆ TEST_FUNC

typedef enum test_return(* TEST_FUNC) (void)

Enumeration Type Documentation

◆ test_return

Enumerator
TEST_SKIP 
TEST_PASS 
TEST_FAIL 

Function Documentation

◆ arithmetic_command()

static off_t arithmetic_command ( char *  buf,
size_t  bufsz,
uint8_t  cmd,
const void *  key,
size_t  keylen,
uint64_t  delta,
uint64_t  initial,
uint32_t  exp 
)
static

◆ binary_hickup_recv_verification_thread()

static void* binary_hickup_recv_verification_thread ( void *  arg)
static

◆ cache_bulkalloc()

static enum test_return cache_bulkalloc ( size_t  datasize)
static

◆ cache_constructor()

static int cache_constructor ( void *  buffer,
void *  notused1,
int  notused2 
)
static

◆ cache_constructor_test()

static enum test_return cache_constructor_test ( void  )
static

◆ cache_create_test()

static enum test_return cache_create_test ( void  )
static

◆ cache_destructor()

static void cache_destructor ( void *  buffer,
void *  notused 
)
static

◆ cache_destructor_test()

static enum test_return cache_destructor_test ( void  )
static

◆ cache_fail_constructor()

static int cache_fail_constructor ( void *  buffer,
void *  notused1,
int  notused2 
)
static

◆ cache_fail_constructor_test()

static enum test_return cache_fail_constructor_test ( void  )
static

◆ cache_redzone_test()

static enum test_return cache_redzone_test ( void  )
static

◆ cache_reuse_test()

static enum test_return cache_reuse_test ( void  )
static

◆ connect_server()

static int connect_server ( const char *  hostname,
in_port_t  port,
bool  nonblock 
)
static

◆ flush_command()

static off_t flush_command ( char *  buf,
size_t  bufsz,
uint8_t  cmd,
uint32_t  exptime,
bool  use_extra 
)
static

◆ lookuphost()

static struct addrinfo* lookuphost ( const char *  hostname,
in_port_t  port 
)
static

◆ main()

int main ( int  argc,
char **  argv 
)

◆ raw_command()

static off_t raw_command ( char *  buf,
size_t  bufsz,
uint8_t  cmd,
const void *  key,
size_t  keylen,
const void *  dta,
size_t  dtalen 
)
static

◆ read_ascii_response()

static void read_ascii_response ( char *  buffer,
size_t  size 
)
static

◆ safe_recv()

static bool safe_recv ( void *  buf,
size_t  len 
)
static

◆ safe_recv_packet()

static bool safe_recv_packet ( void *  buf,
size_t  size 
)
static

◆ safe_send()

static void safe_send ( const void *  buf,
size_t  len,
bool  hickup 
)
static

◆ send_ascii_command()

static void send_ascii_command ( const char *  buf)
static

◆ start_memcached_server()

static enum test_return start_memcached_server ( void  )
static

◆ start_server()

static pid_t start_server ( in_port_t *  port_out,
bool  daemon,
int  timeout 
)
static

Function to start the server and let it listen on a random port.

Parameters
port_outwhere to store the TCP port number the server is listening on
daemonset to true if you want to run the memcached server as a daemon process
timeout
Returns
the pid of the memcached server

◆ stop_memcached_server()

static enum test_return stop_memcached_server ( void  )
static

◆ storage_command()

static off_t storage_command ( char *  buf,
size_t  bufsz,
uint8_t  cmd,
const void *  key,
size_t  keylen,
const void *  dta,
size_t  dtalen,
uint32_t  flags,
uint32_t  exp 
)
static

◆ test_binary_add()

static enum test_return test_binary_add ( void  )
static

◆ test_binary_add_impl()

static enum test_return test_binary_add_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_addq()

static enum test_return test_binary_addq ( void  )
static

◆ test_binary_append()

static enum test_return test_binary_append ( void  )
static

◆ test_binary_appendq()

static enum test_return test_binary_appendq ( void  )
static

◆ test_binary_cas()

static enum test_return test_binary_cas ( void  )
static

◆ test_binary_concat_impl()

static enum test_return test_binary_concat_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_decr()

static enum test_return test_binary_decr ( void  )
static

◆ test_binary_decr_impl()

static enum test_return test_binary_decr_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_decrq()

static enum test_return test_binary_decrq ( void  )
static

◆ test_binary_delete()

static enum test_return test_binary_delete ( void  )
static

◆ test_binary_delete_impl()

static enum test_return test_binary_delete_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_deleteq()

static enum test_return test_binary_deleteq ( void  )
static

◆ test_binary_flush()

static enum test_return test_binary_flush ( void  )
static

◆ test_binary_flush_impl()

static enum test_return test_binary_flush_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_flushq()

static enum test_return test_binary_flushq ( void  )
static

◆ test_binary_get()

static enum test_return test_binary_get ( void  )
static

◆ test_binary_get_impl()

static enum test_return test_binary_get_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_getk()

static enum test_return test_binary_getk ( void  )
static

◆ test_binary_getkq()

static enum test_return test_binary_getkq ( void  )
static

◆ test_binary_getq()

static enum test_return test_binary_getq ( void  )
static

◆ test_binary_getq_impl()

static enum test_return test_binary_getq_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_incr()

static enum test_return test_binary_incr ( void  )
static

◆ test_binary_incr_impl()

static enum test_return test_binary_incr_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_incrq()

static enum test_return test_binary_incrq ( void  )
static

◆ test_binary_noop()

static enum test_return test_binary_noop ( void  )
static

◆ test_binary_pipeline_hickup()

static enum test_return test_binary_pipeline_hickup ( void  )
static

◆ test_binary_pipeline_hickup_chunk()

static enum test_return test_binary_pipeline_hickup_chunk ( void *  buffer,
size_t  buffersize 
)
static

◆ test_binary_prepend()

static enum test_return test_binary_prepend ( void  )
static

◆ test_binary_prependq()

static enum test_return test_binary_prependq ( void  )
static

◆ test_binary_quit()

static enum test_return test_binary_quit ( void  )
static

◆ test_binary_quit_impl()

static enum test_return test_binary_quit_impl ( uint8_t  cmd)
static

◆ test_binary_quitq()

static enum test_return test_binary_quitq ( void  )
static

◆ test_binary_replace()

static enum test_return test_binary_replace ( void  )
static

◆ test_binary_replace_impl()

static enum test_return test_binary_replace_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_replaceq()

static enum test_return test_binary_replaceq ( void  )
static

◆ test_binary_scrub()

static enum test_return test_binary_scrub ( void  )
static

◆ test_binary_set()

static enum test_return test_binary_set ( void  )
static

◆ test_binary_set_impl()

static enum test_return test_binary_set_impl ( const char *  key,
uint8_t  cmd 
)
static

◆ test_binary_setq()

static enum test_return test_binary_setq ( void  )
static

◆ test_binary_stat()

static enum test_return test_binary_stat ( void  )
static

◆ test_binary_verbosity()

static enum test_return test_binary_verbosity ( void  )
static

◆ test_binary_version()

static enum test_return test_binary_version ( void  )
static

◆ test_config_parser()

static enum test_return test_config_parser ( void  )
static

◆ test_issue_101()

static enum test_return test_issue_101 ( void  )
static

◆ test_issue_102()

static enum test_return test_issue_102 ( void  )
static

◆ test_issue_161()

static enum test_return test_issue_161 ( void  )
static

◆ test_issue_44()

static enum test_return test_issue_44 ( void  )
static

◆ test_issue_92()

static enum test_return test_issue_92 ( void  )
static

◆ test_safe_strtof()

static enum test_return test_safe_strtof ( void  )
static

◆ test_safe_strtol()

static enum test_return test_safe_strtol ( void  )
static

◆ test_safe_strtoll()

static enum test_return test_safe_strtoll ( void  )
static

◆ test_safe_strtoul()

static enum test_return test_safe_strtoul ( void  )
static

◆ test_safe_strtoull()

static enum test_return test_safe_strtoull ( void  )
static

◆ test_vperror()

static enum test_return test_vperror ( void  )
static

◆ trim()

static char* trim ( char *  ptr)
static

◆ validate_response_header()

static void validate_response_header ( protocol_binary_response_no_extras *  response,
uint8_t  cmd,
uint16_t  status 
)
static

Variable Documentation

◆ allow_closed_read

bool allow_closed_read = false
static

◆ constructor_pattern

const uint64_t constructor_pattern = 0xdeadcafebabebeef

◆ destruct_data

void* destruct_data = 0
static

◆ hickup_thread_running

volatile bool hickup_thread_running

◆ port

in_port_t port
static

◆ server_pid

pid_t server_pid
static

◆ sock

int sock
static

◆ testcases

struct testcase testcases[]