Merge branch 'develop' into contrib/lwm2m-queue-mode

This commit is contained in:
Joakim Eriksson 2018-05-25 14:49:39 +02:00 committed by GitHub
commit fd4d398f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 55 additions and 17 deletions

View File

@ -65,7 +65,7 @@ static void coap_request_callback(void *callback_data, coap_message_t *response)
/*---------------------------------------------------------------------------*/
static void
static int
progress_request(coap_request_state_t *state) {
coap_message_t *request = state->request;
request->mid = coap_get_mid();
@ -83,7 +83,9 @@ progress_request(coap_request_state_t *state) {
coap_send_transaction(state->transaction);
LOG_DBG("Requested #%"PRIu32" (MID %u)\n", state->block_num, request->mid);
return 1;
}
return 0;
}
/*---------------------------------------------------------------------------*/
@ -134,7 +136,7 @@ coap_request_callback(void *callback_data, coap_message_t *response)
/*---------------------------------------------------------------------------*/
void
int
coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
coap_message_t *request,
void (*callback)(coap_request_state_t *state))
@ -151,7 +153,7 @@ coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
state->remote_endpoint = endpoint;
state->callback = callback;
progress_request(state);
return progress_request(state);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -65,7 +65,15 @@ struct coap_request_state {
void (*callback)(coap_request_state_t *state);
};
void coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
/**
* \brief Send a CoAP request to a remote endpoint
* \param state The state to handle the CoAP request
* \param endpoint The destination endpoint
* \param request The request to be sent
* \param callback callback to execute when the response arrives or the timeout expires
* \return 1 if there is a transaction available to send, 0 otherwise
*/
int coap_send_request(coap_request_state_t *state, coap_endpoint_t *endpoint,
coap_message_t *request,
void (*callback)(coap_request_state_t *state));

View File

@ -1,4 +1,5 @@
#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
@ -16,7 +17,7 @@ sleep 2
echo "Closing native node"
sleep 2
pgrep $CODE | xargs kill -9
kill_bg $CPID
if grep -q "=check-me= FAILED" $CODE.log ; then
echo "==== make.log ====" ; cat make.log;

View File

@ -1,4 +1,5 @@
#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
@ -38,8 +39,8 @@ HOPS=`wc $BASENAME.scriptlog -l | cut -f 1 -d ' '`
echo "Closing simulation and tunslip6"
sleep 1
kill -9 $JPID
kill -9 $MPID
kill_bg $JPID
kill_bg $MPID
sleep 1
rm COOJA.testlog
rm COOJA.log

View File

@ -1,4 +1,5 @@
#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
@ -22,7 +23,7 @@ STATUS=${PIPESTATUS[0]}
echo "Closing native node"
sleep 2
pgrep hello-world | sudo xargs kill -9
kill_bg $CPID
if [ $STATUS -eq 0 ] ; then
cp $BASENAME.log $BASENAME.testlog

View File

@ -1,4 +1,5 @@
#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
@ -38,7 +39,7 @@ done
echo "Closing native node"
sleep 2
pgrep coap-example | sudo xargs kill -9
kill_bg $CPID
if [ $TESTCOUNT -eq $OKCOUNT ] ; then
printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog;

View File

@ -1,4 +1,5 @@
#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
@ -44,8 +45,8 @@ REPLIES=`grep -c 'icmp_seq=' $BASENAME.scriptlog`
echo "Closing simulation and tunslip6"
sleep 1
kill -9 $JPID
kill -9 $MPID
kill_bg $JPID
kill_bg $MPID
sleep 1
rm COOJA.testlog
rm COOJA.log

View File

@ -1,4 +1,5 @@
#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
@ -43,8 +44,8 @@ REPLIES=`grep -c 'icmp_seq=' $BASENAME.scriptlog`
echo "Closing simulation and nbr"
sleep 1
kill -9 $JPID
kill -9 $MPID
kill_bg $JPID
kill_bg $MPID
sleep 1
rm COOJA.testlog
rm COOJA.log

View File

@ -1,4 +1,5 @@
#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
@ -32,11 +33,11 @@ done
echo "Closing native node"
sleep 1
pgrep ipso | sudo xargs kill -9
kill_bg $CPID
echo "Closing leshan"
sleep 1
pgrep java | sudo xargs kill -9
kill_bg $LESHID
if grep -q 'OK' leshan.err ; then

View File

@ -1,4 +1,5 @@
#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
@ -33,11 +34,11 @@ done
echo "Closing standalone example"
sleep 1
pgrep lwm2m-example | sudo xargs kill -9
kill_bg $CPID
echo "Closing leshan"
sleep 1
pgrep java | sudo xargs kill -9
kill_bg $LESHID
if grep -q 'OK' leshan.err ; then

20
tests/utils.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
function echo_run( )
{
echo $@
$@
}
function kill_bg( )
{
PID=$1
CMD=$(ps -p $PID -o cmd=)
SUDO=
TOKILL=$PID
if [[ ${CMD:0:5} == "sudo " ]] ; then
SUDO="sudo "
TOKILL=$(ps --ppid $PID -o pid=)
fi
echo_run ${SUDO}kill -9 $TOKILL
}