Skip to content

Commit

Permalink
AXL_Init and AXL_Finalize CI testing works
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfadden8 committed Jul 2, 2024
1 parent e9082d7 commit be8daad
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
14 changes: 9 additions & 5 deletions src/axl_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static kvtree* service_request_AXL_Config_Set(int sd)
}
#endif

static ssize_t service_request_from_client(int sd)
static ssize_t axl_socket_request_from_client(int sd)
{
ssize_t bytecount;
axl_socket_Request req;
Expand Down Expand Up @@ -171,6 +171,7 @@ static ssize_t service_request_from_client(int sd)

static void sigterm_handler(int sig, siginfo_t* info, void* ucontext)
{
AXL_DBG(2, "SIGTERM Received");
time_to_leave++;
}

Expand Down Expand Up @@ -250,12 +251,15 @@ int axl_socket_server_run(int port)

activity = select(max_sd + 1 , &readfds , NULL , NULL , NULL);

if (time_to_leave)
break;

if (activity < 0 && errno != EINTR) {
AXL_ABORT(-1, "select() error: (%s)", strerror(errno));
}

if (FD_ISSET(server_socket, &readfds)) {
AXL_DBG(0, "Accepting new incomming connection");
AXL_DBG(1, "Accepting new incomming connection");
if ((new_socket = accept(server_socket, (struct sockaddr *)&address,
(socklen_t*)&addrlen)) < 0) {
AXL_ABORT(-1, "accept() error: (%s)", strerror(errno));
Expand All @@ -267,15 +271,15 @@ int axl_socket_server_run(int port)
break;
}
}
AXL_DBG(0, "Connection established");
AXL_DBG(1, "Connection established");
}

for ( int i = 0; i < AXL_SOCKET_MAX_CLIENTS; i++) {
if (FD_ISSET(axl_socket_conn_ctx_array[i].sd , &readfds)) {
axl_xfer_list = &axl_socket_conn_ctx_array[i].xfr;

if (service_request_from_client(axl_socket_conn_ctx_array[i].sd) == 0) {
AXL_DBG(0, "Closing server side socket(%d) to client", axl_socket_conn_ctx_array[i].sd);
if (axl_socket_request_from_client(axl_socket_conn_ctx_array[i].sd) == 0) {
AXL_DBG(1, "Closing server side socket(%d) to client", axl_socket_conn_ctx_array[i].sd);
close(axl_socket_conn_ctx_array[i].sd);
axl_socket_conn_ctx_array[i].sd = 0;
axl_free(&axl_xfer_list->axl_kvtrees);
Expand Down
15 changes: 11 additions & 4 deletions test/test_client_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ int run_service()

int run_client()
{
fprintf(stdout, "Client Started!\n");
sleep(2);
fprintf(stdout, "Client Ending!\n");
return AXLCS_SUCCESS;
int rval;

if ((rval = AXL_Init()) != AXL_SUCCESS) {
fprintf(stderr, "Call to AXL_Init failed with code: %d\n", rval);
} else {
if ((rval = AXL_Finalize()) != AXL_SUCCESS) {
fprintf(stderr, "Call to AXL_Init failed with code: %d\n", rval);
}
}

return rval;
}

int main(int ac, char **av)
Expand Down
8 changes: 6 additions & 2 deletions test/test_driver_client_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import subprocess
import os
import time

def wait_for_completion(procname, proc, wait_time):
try:
Expand All @@ -20,8 +21,11 @@ def wait_for_completion(procname, proc, wait_time):
if __name__ == '__main__':
errors = 0
# Launch the server then the client
server = subprocess.Popen(['./test_client_server', '--server'], env=dict(os.environ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
client = subprocess.Popen(['./test_client_server', '--client'], env=dict(os.environ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
test_env = {'AXL_DEBUG': '44', 'AXL_SERVICE_HOST': 'localhost', 'AXL_SERVICE_PORT': '2000'}
server = subprocess.Popen(['./test_client_server', '--server'], env=dict(os.environ, **test_env), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
time.sleep(2) # Give server a chance to start

client = subprocess.Popen(['./test_client_server', '--client'], env=dict(os.environ, **test_env), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)

# Wait for the client then the server to finish
client_ecode, client_out, client_err = wait_for_completion("axl_client", client, 30)
Expand Down

0 comments on commit be8daad

Please sign in to comment.