Commit c1d1b722 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Fix several issues with tests + some bugs

Bump spdlog to 0.13.0
Bump catch to 2.0
parent 69dbbdae
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -237,6 +237,9 @@ ssize_t norns_progress(struct norns_iotd* iotdp, struct norns_iotst* statp) __TH
/* Retrieve error status associated with iotdp */
int norns_error(struct norns_iotd* iotdp) __THROW;

/* Check if the urd daemon is running */
int norns_ping() __THROW;


/**************************************************************************/
/* Administrative API                                                     */
+27 −0
Original line number Diff line number Diff line
@@ -115,6 +115,15 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) {
            break;
        }

        case NORNS_PING:
        {
            if((res = pack_to_buffer(type, &req_buf)) != NORNS_SUCCESS) {
                return res;
            }

            break;
        }

        default:
            return NORNS_ESNAFU;

@@ -299,6 +308,24 @@ send_process_request(norns_rpc_type_t type, struct norns_cred* auth,
    return resp.r_status;
}

int
send_ping_request() {

    int res;
    norns_response_t resp;

    if((res = send_request(NORNS_PING, &resp)) != NORNS_SUCCESS) {
        return res;
    }

    if(resp.r_type != NORNS_PING) {
        return NORNS_ESNAFU;
    }

    return resp.r_status;

}

static int connect_to_daemon(void) {

	struct sockaddr_un server;
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ int send_job_request(norns_rpc_type_t type, struct norns_cred* auth,
                     uint32_t jobid, struct norns_job* job);
int send_process_request(norns_rpc_type_t type, struct norns_cred* auth, 
                         uint32_t jobid, uid_t uid, gid_t gid, pid_t pid);
int send_ping_request();

#pragma GCC visibility pop

+6 −0
Original line number Diff line number Diff line
@@ -114,3 +114,9 @@ norns_remove_process(struct norns_cred* auth, uint32_t jobid, uid_t uid,
    return send_process_request(NORNS_REMOVE_PROCESS, auth, jobid, 
                                uid, gid, pid);
}


int
norns_ping() {
    return send_ping_request();
}
+14 −1
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ remap_request(norns_rpc_type_t type) {
            return NORNS__RPC__REQUEST__TYPE__ADD_PROCESS;
        case NORNS_REMOVE_PROCESS:
            return NORNS__RPC__REQUEST__TYPE__REMOVE_PROCESS;
        case NORNS_PING:
            return NORNS__RPC__REQUEST__TYPE__PING;
        default:
            return -1;
    }
@@ -73,6 +75,8 @@ remap_response(int norns_rpc_type) {
            return NORNS_ADD_PROCESS;
        case NORNS__RPC__RESPONSE__TYPE__REMOVE_PROCESS:
            return NORNS_REMOVE_PROCESS;
        case NORNS__RPC__RESPONSE__TYPE__PING:
            return NORNS_PING;
        case NORNS__RPC__RESPONSE__TYPE__BAD_REQUEST:
            // intentionally fall through
        default:
@@ -91,7 +95,7 @@ build_request_msg(norns_rpc_type_t type, va_list ap) {

    norns__rpc__request__init(req_msg);

    req_msg->type = type;
    //req_msg->type = type;

    switch(type) {
        case NORNS_SUBMIT_IOTASK:
@@ -166,6 +170,15 @@ build_request_msg(norns_rpc_type_t type, va_list ap) {

            break;
        }

        case NORNS_PING:
        {

            if((req_msg->type = remap_request(type)) < 0) {
                goto cleanup_on_error;
            }
            break;
        }
    }

    return req_msg;
Loading