Skip to content
Snippets Groups Projects
Commit 7bd3c2d9 authored by TwilCynder's avatar TwilCynder
Browse files

documentation

parent 31839efc
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,13 @@
#include <unistd.h>
#include <stdlib.h>
/**
* @brief Runs mojitos in parallel, and performs a set of tests on this run.
*
* Initializes each test, calls their reader function for each output of mojitos, and then finalizes them and prints the given result.
*
* @param execution object that has the arguments for mojitos as well as the tests to be performed.
*/
void execute_test(Execution *execution)
{
for (int i = 0; i < execution->nb_testers; i++) {
......@@ -11,7 +18,6 @@ void execute_test(Execution *execution)
tester->init(&tester->state, execution->context);
}
int downstream[2];
int upstream[2];
pipe(downstream);
......@@ -51,4 +57,6 @@ void execute_test(Execution *execution)
printf("- %s\n", tester->name);
printf("-> %s\n", tester->finalize(tester->state, execution->context) ? "Failed" : "Passed");
}
close(upstream[0]);
}
......@@ -4,15 +4,19 @@
extern char path[];
/**
* @brief All the info needed to perform a set of tests on one run of mojitos
*/
typedef struct {
char *const *args;
Tester *testers;
int nb_testers;
void *context;
char *const *args; //Arguments to be passed to mojitos
Tester *testers; //Tests that are going to be performed (concurrently) durning this run.
int nb_testers; //Number of tests.
void *context; //Pointer to an object containing the context for this run (we can modify its content and then reuse the same Execution to run multiple test runs with the same tests.)
} Execution;
void execute_test(Execution *execution);
#define PRINT(__fmt, ...) \
printf("-> "); \
printf(__fmt, ##__VA_ARGS__);
/*******************************************************
Copyright (C) 2018-2023 Georges Da Costa <georges.da-costa@irit.fr>
This file is part of Mojitos.
Mojitos is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Mojitos is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MojitO/S. If not, see <https://www.gnu.org/licenses/>.
*******************************************************/
#include <stdlib.h>
#include <stdio.h>
#include "../execution.h"
......@@ -49,10 +69,21 @@ int timing_finalize(void* state, void* context){
return abs(count - expected) <= TOLERANCE;
}
/**
* @brief Calculates the number of expected outputs from the duration of frequency (in the form of strings).
*
* May be a signficantly useless overhead given that i could have just hard-coded the result as an int, but wanted
* to make sure that there is no error on this value. Also, we go from string to int instead of having exerything coded as int
* and then converting to string to be passed to the exec because string->int costs less than int->string with static strings.
* @param args the TimingExecutionArgs containing our two values as strings.
*/
int calc_expected_result(TimingExecutionArgs* args){
return atoi(args->duration) * atoi(args->frequency);
}
/**
* @brief Performs all the timing related tests.
*/
void timing_test(){
Tester tester = {
.init = timing_init,
......
/*******************************************************
Copyright (C) 2018-2023 Georges Da Costa <georges.da-costa@irit.fr>
This file is part of Mojitos.
Mojitos is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Mojitos is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MojitO/S. If not, see <https://www.gnu.org/licenses/>.
*******************************************************/
#pragma once
///
/// Returns the length of a given static array
#define ARRAY_LENGTH(array) sizeof(array) / sizeof(*array)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment