here_doc: print error if failed to create temp file

This commit is contained in:
Khaïs COLIN 2025-03-28 18:28:27 +01:00
parent 66ea1328aa
commit 1c4733b1cc
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
4 changed files with 37 additions and 6 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/07 11:43:32 by khais #+# #+# */
/* Updated: 2025/03/28 16:41:08 by khais ### ########.fr */
/* Updated: 2025/03/28 19:05:55 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,6 +17,7 @@
#include <fcntl.h>
#include "../src/executing/here_doc/here_doc.h"
#include "../src/env/env_manip.h"
#include "../src/ft_errno.h"
static void test_here_doc_filename_generation(void)
{
@ -24,6 +25,7 @@ static void test_here_doc_filename_generation(void)
char *filename2;
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
ft_errno(FT_ESUCCESS);
filename1 = here_doc_random_filename();
filename2 = here_doc_random_filename();
assert(filename1 != NULL);
@ -41,6 +43,7 @@ static void test_here_doc_invalid_args(void)
t_worddesc *marker;
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
ft_errno(FT_ESUCCESS);
assert(-1 == here_doc(NULL, 0, NULL));
marker = worddesc_create(NULL, 0, NULL);
assert(-1 == here_doc(marker, 0, NULL));
@ -58,6 +61,7 @@ static void test_here_doc_only_end_marker(void)
int result;
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
ft_errno(FT_ESUCCESS);
marker = worddesc_create(ft_strdup("EOF"), 0, NULL);
infile = open("./here_doc_only_eof.input", O_RDONLY);
result = here_doc(marker, infile, NULL);
@ -76,6 +80,7 @@ static void test_here_doc_input_plus_end_marker(void)
int result;
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
ft_errno(FT_ESUCCESS);
marker = worddesc_create(ft_strdup("EOF"), 0, NULL);
infile = open("./here_doc_input_plus_eof.input", O_RDONLY);
result = here_doc(marker, infile, NULL);
@ -115,6 +120,7 @@ static void test_here_doc_with_expansion(void)
ft_bzero(&app, sizeof(t_minishell));
app.env = env_set_entry(&app.env, ft_strdup("USER"), ft_strdup("kcolin"));
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
ft_errno(FT_ESUCCESS);
marker = worddesc_create(ft_strdup("EOF"), 0, NULL);
infile = open("./here_doc_with_expansion.input", O_RDONLY);
result = here_doc(marker, infile, &app);