Skip to content
Extraits de code Groupes Projets
Valider 3ab6ae6b rédigé par Samuel de Meester de Ravestein's avatar Samuel de Meester de Ravestein
Parcourir les fichiers

general function to generate tests is working

parent 00672c0c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -58,16 +58,15 @@ bool can_send(sender_state_t *state)
}
else if (state->last_pkt_sent == LAST_DATA_PKT)
{
// I want to be sure all the data pkt has been received before letting know the receiver
// I want to be sure that all the PTYPE_DATA have been received before letting know the receiver
// it was the end of the file (so that I can set a timer for timeout)
return state->s_window_size == MAX_WINDOW_SIZE;
}
// Case: we're in FEC mode, the closing pkt has been sent but we will still send a last FEC if possible
else if ((state->fec_enabled) && (state->last_pkt_sent == CLOSING_PKT) && (state->FEC_nbr > 0))
// Case: we're in FEC mode, the closing pkt has been sent but we still want to send a last FEC if 4 PTYPE_DATA have been stacked
else if ((state->fec_enabled) && (state->last_pkt_sent == CLOSING_PKT) && (state->FEC_nbr == 4))
{
return true;
}
// Case last FEC has been sended
else
{
return false;
......@@ -269,10 +268,14 @@ void construct_FEC(sender_state_t *state, pkt_t *pkt)
uint8_t payload[MAX_PAYLOAD_SIZE];
uint8_t *p1 = (uint8_t *) pkt_get_payload(state->FEC);
uint8_t *p2 = (uint8_t *) pkt_get_payload(pkt);
for (int i = 0; i < MAX_PAYLOAD_SIZE; i++)
for (int i = 0; i < pkt_get_length(pkt); i++)
{
payload[i] = p1[i] ^ p2[i];
}
for (int i = pkt_get_length(pkt); i < MAX_PAYLOAD_SIZE; i++)
{
payload[i] = p1[i];
}
pkt_set_payload(state->FEC, (const char *) payload, MAX_PAYLOAD_SIZE);
state->FEC_nbr++;
......@@ -313,7 +316,7 @@ int send_FEC(sender_state_t *state, int socket_fd)
int read_and_send(sender_state_t *state, int sending_fd, int socket_fd)
{
// Checking whether I need to send a PTYPE_FEC or PTYPE_DATA
if ((state->fec_enabled) && ((state->FEC_nbr == 4) || ((state->last_pkt_sent == CLOSING_PKT) && (state->FEC_nbr > 0))))
if (state->fec_enabled && (state->FEC_nbr == 4))
{
return send_FEC(state, socket_fd);
}
......
......@@ -47,6 +47,8 @@ if [ -d "${DIR}" ]; then
fi
mkdir "${DIR}" 2>/dev/null
echo -e "\nSimulation ${mode}"
# Checking if we're using the linksimulator or not
if [ "$#" -gt 6 ]; then
......@@ -59,7 +61,7 @@ if [ "$#" -gt 6 ]; then
echo -e "The linksimulator paramateres are:
\t\t-ERROR RATE: ${ERROR_RATE}% \t-DELAY: ${DELAY}ms
\t\t-CUT RATE: ${CUT_RATE}% \t-JITTER: ${JITTER}ms
\t\t-LOSS RATE: ${LOSS_RATE}%\n"
\t\t-LOSS RATE: ${LOSS_RATE}%"
# The next 2 lines come from: https://unix.stackexchange.com/questions/55913/whats-the-easiest-way-to-find-an-unused-local-port
# We use this to be sure we're using unused port
......@@ -140,6 +142,8 @@ else # We check the return value of the receiver
echo -e "${RED}Crash of the receiver!${NC}"
cat ${receiver_logs}
err=1
else
err=0
fi
fi
......
......@@ -3,6 +3,10 @@
BROWN='\033[0;33m'
NC='\033[0m'
my_sender="sender"
my_receiver="receiver"
# Note that this assumes to be called from the Makefile, you may want to adapt it.
FILESIZE=""
TEST_FILES_DIR=./tests_files/
......@@ -44,21 +48,36 @@ advanced_test_files=(
# let i++
# done
echo -e "Finished Simple tests."
# echo -e "Finished Simple tests."
modes=(
'with_FEC'
'without_FEC'
)
ERROR_RATE=5
CUT_RATE=5
DELAY=100
JITTER=100
LOSS_RATE=1
dir="tests_logs/advanced_tests/"
if [ -d linksimulator/ ]; then
echo -e "\nStarting advanced tests ...\n"
# Now we ran the advanced tests
i=1
for FILENAME in "${advanced_test_files[@]}"; do
FILESIZE=$(stat -c%s "$FILENAME")
echo -e "\n${BROWN}($i/${#advanced_test_files[@]}) Sending the file \"$FILENAME\" \t[$FILESIZE bytes] with linksimulator and Valgrind${NC}"
./tests/advanced_test.sh $FILENAME
if [ $? -ne 0 ]; then
echo "Tests terminated cause of a failed test"
exit 0
fi
for file in "${advanced_test_files[@]}"; do
filesize=$(stat -c%s "$file")
echo -e "\n${BROWN}($i/${#advanced_test_files[@]}) Sending the file \"$file\" \t[$filesize bytes] with linksimulator and Valgrind${NC}"
for mode in "${modes[@]}"; do
./tests/run_sender_receiver.sh $my_sender $my_receiver $file $dir $mode \
$ERROR_RATE $CUT_RATE $DELAY $JITTER $LOSS_RATE
if [ $? -ne 0 ]; then
echo "Tests terminated cause of a failed test"
exit 0
fi
done
let i++
done
echo "Finished Advanced tests."
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter