feat/stdout (#3)
* feat: disable standard output for tests * fuck les fds * patch some complation issues * style: norm * feat: timeout * fix: patc more stuff * fix: patch merge * feat: more tests
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:32:32 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/24 16:47:43 by elagouch ### ########.fr */
|
||||
/* Updated: 2026/01/25 16:41:49 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -18,10 +18,15 @@ int libunit_launcher(void)
|
||||
size_t res;
|
||||
|
||||
testlist = NULL;
|
||||
load_test(&testlist, "successful", &test_ok);
|
||||
load_test(&testlist, "unsuccessful", &test_ko);
|
||||
load_test(&testlist, "sigsegv", &test_sigsegv);
|
||||
load_test(&testlist, "sigbus", &test_sigbus);
|
||||
load_test(&testlist, "successful", &test_ok, 0);
|
||||
load_test(&testlist, "unsuccessful", &test_ko, 0);
|
||||
load_test(&testlist, "sigsegv", &test_sigsegv, 0);
|
||||
load_test(&testlist, "sigbus", &test_sigbus, 0);
|
||||
load_test(&testlist, "sigkill", &test_sigkill, 0);
|
||||
load_test(&testlist, "sigabrt", &test_sigabrt, 0);
|
||||
load_test(&testlist, "sigfpe", &test_sigfpe, 0);
|
||||
load_test(&testlist, "sigpipe", &test_sigpipe, 0);
|
||||
load_test(&testlist, "timeout", &test_timeout, 1);
|
||||
res = launch_tests(testlist, "libunit");
|
||||
clear_tests(&testlist);
|
||||
return (res);
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/24 16:16:32 by elagouch ### ########.fr */
|
||||
/* Updated: 2026/01/25 16:36:02 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int test_ok(void)
|
||||
{
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/24 16:16:37 by elagouch ### ########.fr */
|
||||
/* Updated: 2026/01/25 16:36:07 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int test_ko(void)
|
||||
{
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/24 16:19:43 by elagouch ### ########.fr */
|
||||
/* Updated: 2026/01/25 16:36:33 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <signal.h>
|
||||
#include "../tests.h"
|
||||
|
||||
int test_sigsegv(void)
|
||||
{
|
||||
raise(SIGSEGV);
|
||||
return (ft_atoi(NULL) == 0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -6,14 +6,20 @@
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/24 16:19:50 by elagouch ### ########.fr */
|
||||
/* Updated: 2026/01/25 15:22:52 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int test_sigbus(void)
|
||||
{
|
||||
raise(SIGBUS);
|
||||
return (1);
|
||||
char *cptr;
|
||||
int *iptr;
|
||||
|
||||
__asm__("pushf\norl $0x40000,(%rsp)\npopf");
|
||||
cptr = malloc(sizeof(int) + 1);
|
||||
iptr = (int *)++cptr;
|
||||
*iptr = 42;
|
||||
return (1);
|
||||
}
|
||||
|
||||
19
tests/libunit/05_sigkill.c
Normal file
19
tests/libunit/05_sigkill.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 05_sigkill.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/25 16:38:20 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
int test_sigkill(void)
|
||||
{
|
||||
raise(SIGKILL);
|
||||
return (1);
|
||||
}
|
||||
19
tests/libunit/06_sigabrt.c
Normal file
19
tests/libunit/06_sigabrt.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 06_sigabrt.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/25 16:38:37 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
int test_sigabrt(void)
|
||||
{
|
||||
raise(SIGABRT);
|
||||
return (1);
|
||||
}
|
||||
19
tests/libunit/07_sigfpe.c
Normal file
19
tests/libunit/07_sigfpe.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 07_sigfpe.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/25 16:39:11 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
int test_sigfpe(void)
|
||||
{
|
||||
raise(SIGFPE);
|
||||
return (1);
|
||||
}
|
||||
19
tests/libunit/08_sigpipe.c
Normal file
19
tests/libunit/08_sigpipe.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 08_sigpipe.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/25 16:39:33 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
int test_sigpipe(void)
|
||||
{
|
||||
raise(SIGPIPE);
|
||||
return (1);
|
||||
}
|
||||
18
tests/libunit/09_timeout.c
Normal file
18
tests/libunit/09_timeout.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 09_timeout.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */
|
||||
/* Updated: 2026/01/25 16:40:07 by elagouch ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int test_timeout(void)
|
||||
{
|
||||
while(1)
|
||||
{}
|
||||
return (1);
|
||||
}
|
||||
Reference in New Issue
Block a user