mirror of
				https://github.com/open5gs/open5gs.git
				synced 2025-11-04 05:53:18 +00:00 
			
		
		
		
	improve testcode terminate routine.
This commit is contained in:
		
							
								
								
									
										13
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								main.c
									
									
									
									
									
								
							@@ -60,6 +60,12 @@ static int check_signal(int signum)
 | 
				
			|||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void terminate()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    app_terminate();
 | 
				
			||||||
 | 
					    core_terminate();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char *argv[])
 | 
					int main(int argc, char *argv[])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**************************************************************************
 | 
					    /**************************************************************************
 | 
				
			||||||
@@ -117,12 +123,12 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
    show_version();
 | 
					    show_version();
 | 
				
			||||||
    d_print("\n");
 | 
					    d_print("\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    atexit(terminate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    core_initialize();
 | 
					    core_initialize();
 | 
				
			||||||
    if (app_initialize(config_path, log_path) != CORE_OK)
 | 
					    if (app_initialize(config_path, log_path) != CORE_OK)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        d_fatal("NextEPC initialization failed. Aborted");
 | 
					        d_fatal("NextEPC initialization failed. Aborted");
 | 
				
			||||||
        app_terminate();
 | 
					 | 
				
			||||||
        core_terminate();
 | 
					 | 
				
			||||||
        return EXIT_FAILURE;
 | 
					        return EXIT_FAILURE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -132,8 +138,5 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    d_info("NextEPC daemon terminating...");
 | 
					    d_info("NextEPC daemon terminating...");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    app_terminate();
 | 
					 | 
				
			||||||
    core_terminate();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return EXIT_SUCCESS;
 | 
					    return EXIT_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -429,7 +429,10 @@ int main(int argc, const char *const argv[]) {
 | 
				
			|||||||
    int list_provided = 0;
 | 
					    int list_provided = 0;
 | 
				
			||||||
    abts_suite *suite = NULL;
 | 
					    abts_suite *suite = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    test_initialize();
 | 
					    rv = test_initialize();
 | 
				
			||||||
 | 
					    if (rv != CORE_OK) 
 | 
				
			||||||
 | 
					        return EXIT_FAILURE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    d_trace_global_off();
 | 
					    d_trace_global_off();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    quiet = !isatty(STDOUT_FILENO);
 | 
					    quiet = !isatty(STDOUT_FILENO);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,23 +24,6 @@
 | 
				
			|||||||
#include "abts.h"
 | 
					#include "abts.h"
 | 
				
			||||||
#include "testutil.h"
 | 
					#include "testutil.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
void core_assert_ok(abts_case* tc, const char* context, status_t rv,
 | 
					 | 
				
			||||||
                        int lineno)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    if (rv == CORE_ENOTIMPL)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        abts_not_impl(tc, context, lineno);
 | 
					 | 
				
			||||||
    } else if (rv != CORE_OK)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        char buf[STRING_MAX], ebuf[128];
 | 
					 | 
				
			||||||
        sprintf(buf, "%s (%d): %s\n", context, rv,
 | 
					 | 
				
			||||||
                core_strerror(rv, ebuf, sizeof ebuf));
 | 
					 | 
				
			||||||
        abts_fail(tc, buf, lineno);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static semaphore_id test_sem;
 | 
					static semaphore_id test_sem;
 | 
				
			||||||
static void test_s6a_hook_handler(enum fd_hook_type type, struct msg * msg, 
 | 
					static void test_s6a_hook_handler(enum fd_hook_type type, struct msg * msg, 
 | 
				
			||||||
    struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, 
 | 
					    struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, 
 | 
				
			||||||
@@ -61,23 +44,29 @@ void test_terminate(void)
 | 
				
			|||||||
    core_terminate();
 | 
					    core_terminate();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void test_initialize(void)
 | 
					status_t test_initialize(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    status_t rv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    s6a_hook_register(test_s6a_hook_handler);
 | 
					    s6a_hook_register(test_s6a_hook_handler);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    atexit(test_terminate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    core_initialize();
 | 
					    core_initialize();
 | 
				
			||||||
    d_assert(semaphore_create(&test_sem, 0) == CORE_OK, 
 | 
					    d_assert(semaphore_create(&test_sem, 0) == CORE_OK, 
 | 
				
			||||||
            return, "semaphore_create() failed");
 | 
					            return CORE_ERROR, "semaphore_create() failed");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    app_initialize(NULL, NULL);
 | 
					    rv = app_initialize(NULL, NULL);
 | 
				
			||||||
 | 
					    if (rv == CORE_OK)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        d_assert(semaphore_wait(test_sem) == CORE_OK, return CORE_ERROR,
 | 
				
			||||||
 | 
					                "semaphore_wait() failed");
 | 
				
			||||||
 | 
					        d_assert(semaphore_wait(test_sem) == CORE_OK, return CORE_ERROR,
 | 
				
			||||||
 | 
					                "semaphore_wait() failed");
 | 
				
			||||||
 | 
					        d_assert(semaphore_delete(test_sem) == CORE_OK, return CORE_ERROR,
 | 
				
			||||||
 | 
					                "semaphore_delete() failed");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    d_assert(semaphore_wait(test_sem) == CORE_OK, return,
 | 
					    return rv;
 | 
				
			||||||
            "semaphore_wait() failed");
 | 
					 | 
				
			||||||
    d_assert(semaphore_wait(test_sem) == CORE_OK, return,
 | 
					 | 
				
			||||||
            "semaphore_wait() failed");
 | 
					 | 
				
			||||||
    d_assert(semaphore_delete(test_sem) == CORE_OK, return,
 | 
					 | 
				
			||||||
            "semaphore_delete() failed");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    atexit(test_terminate);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,7 +55,7 @@ void core_assert_ok(abts_case* tc, const char *context,
 | 
				
			|||||||
#define CORE_ASSERT_OK(tc, ctxt, rv) \
 | 
					#define CORE_ASSERT_OK(tc, ctxt, rv) \
 | 
				
			||||||
             core_assert_ok(tc, ctxt, rv, __LINE__)
 | 
					             core_assert_ok(tc, ctxt, rv, __LINE__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void test_initialize(void);
 | 
					status_t test_initialize(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
abts_suite *test_base(abts_suite *suite);
 | 
					abts_suite *test_base(abts_suite *suite);
 | 
				
			||||||
abts_suite *test_s1ap_message(abts_suite *suite);
 | 
					abts_suite *test_s1ap_message(abts_suite *suite);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user