Line data Source code
1 1 : /** 2 : * @file test/gvt/gvt_test.c 3 : * 4 : * @brief Test: parallel gvt algorithm 5 : * 6 : * SPDX-FileCopyrightText: 2008-2021 HPDCS Group <rootsim@googlegroups.com> 7 : * SPDX-License-Identifier: GPL-3.0-only 8 : */ 9 : #include <test.h> 10 : 11 : #include <core/init.h> 12 : #include <gvt/gvt.h> 13 : 14 0 : #define N_THREADS 3 15 : 16 0 : static simtime_t bound_values[N_THREADS][6] = { 17 : {1.1, 4.1, 6.7, 7.0, 9.8, 10.0}, 18 : {2.0, 3.4, 6.5, 6.5, 9.6, 11.0}, 19 : {1.2, 3.5, 6.4, 6.3, 9.7, 10.5}, 20 : }; 21 0 : static __thread unsigned b_i = 0; 22 : 23 1 : simtime_t msg_queue_time_peek(void) 24 : { 25 : return bound_values[rid][b_i++]; 26 : } 27 : 28 : struct simulation_configuration global_config = { 29 : .gvt_period = 1000 30 : }; 31 : 32 : 33 0 : static int gvt_test_init(void) 34 : { 35 : gvt_global_init(); 36 : return 0; 37 : } 38 : 39 0 : static int gvt_test(void) 40 : { 41 : int ret = 0; 42 : 43 : while(!gvt_msg_processed()); 44 : ret -= current_gvt != 1.1; 45 : 46 : while(!gvt_msg_processed()); 47 : ret -= current_gvt != 6.3; 48 : 49 : while(!gvt_msg_processed()); 50 : ret -= current_gvt != 9.6; 51 : 52 : return ret; 53 : } 54 : 55 : const struct test_config test_config = { 56 : .threads_count = N_THREADS, 57 : .test_init_fnc = gvt_test_init, 58 : .test_fnc = gvt_test 59 : }; 60 :