Closed nekitoss closed 7 years ago
Hello,
are you on the linux branch of the project ?
okay, that was my fault. Plz add to description that user has to change branch! Also i had to change shell - /bin/bash worked for me (also will be good to see in description) but i still get an error (-v did not changed output) :
$ make re
\033[38;5;46m make re -C ../libft \033[31m
make[1]: Entering directory `/home/username/libft'
/bin/rm -f ft_bzero.o ft_isdigit.o ft_memset.o ft_strcmp.o ft_strlen.o ft_strnstr.o ft_toupper.o ft_isalnum.o ft_isprint.o ft_strcat.o ft_strcpy.o ft_strncat.o ft_strrchr.o ft_isalpha.o ft_memccpy.o ft_strchr.o ft_strdup.o ft_strncmp.o ft_strstr.o ft_atoi.o ft_isascii.o ft_memcpy.o ft_strclr.o ft_strlcat.o ft_strncpy.o ft_tolower.o ft_memmove.o ft_memchr.o ft_memcmp.o
/bin/rm -f libft.a
gcc -Wall -Werror -Wextra -I./ -c ft_bzero.c ft_isdigit.c ft_memset.c ft_strcmp.c ft_strlen.c ft_strnstr.c ft_toupper.c ft_isalnum.c ft_isprint.c ft_strcat.c ft_strcpy.c ft_strncat.c ft_strrchr.c ft_isalpha.c ft_memccpy.c ft_strchr.c ft_strdup.c ft_strncmp.c ft_strstr.c ft_atoi.c ft_isascii.c ft_memcpy.c ft_strclr.c ft_strlcat.c ft_strncpy.c ft_tolower.c ft_memmove.c ft_memchr.c ft_memcmp.c
ar rc libft.a ft_bzero.o ft_isdigit.o ft_memset.o ft_strcmp.o ft_strlen.o ft_strnstr.o ft_toupper.o ft_isalnum.o ft_isprint.o ft_strcat.o ft_strcpy.o ft_strncat.o ft_strrchr.o ft_isalpha.o ft_memccpy.o ft_strchr.o ft_strdup.o ft_strncmp.o ft_strstr.o ft_atoi.o ft_isascii.o ft_memcpy.o ft_strclr.o ft_strlcat.o ft_strncpy.o ft_tolower.o ft_memmove.o ft_memchr.o ft_memcmp.o
ranlib libft.a
make[1]: Leaving directory `/home/username/libft'
\033[38;5;196;m[ Cleaning #0 ]\033[0m
\033[38;5;196m➤ \033[38;5;9m rm -f obj/main.o obj/test_functions.o obj/display_test_result.o obj/signal.o obj/sandbox.o obj/bench_functions.o \033[31m
\033[38;5;196m➤ \033[38;5;9m rm -f libft.so assets/libft.a assetslibtests assets/malloc.dylib \033[31m
\033[38;5;196m➤ \033[38;5;9m rm -f run_test \033[31m
\033[38;5;46m make -C ../libft \033[31m
make[1]: Entering directory `/home/username/libft'
gcc -Wall -Werror -Wextra -I./ -c ft_bzero.c ft_isdigit.c ft_memset.c ft_strcmp.c ft_strlen.c ft_strnstr.c ft_toupper.c ft_isalnum.c ft_isprint.c ft_strcat.c ft_strcpy.c ft_strncat.c ft_strrchr.c ft_isalpha.c ft_memccpy.c ft_strchr.c ft_strdup.c ft_strncmp.c ft_strstr.c ft_atoi.c ft_isascii.c ft_memcpy.c ft_strclr.c ft_strlcat.c ft_strncpy.c ft_tolower.c ft_memmove.c ft_memchr.c ft_memcmp.c
ar rc libft.a ft_bzero.o ft_isdigit.o ft_memset.o ft_strcmp.o ft_strlen.o ft_strnstr.o ft_toupper.o ft_isalnum.o ft_isprint.o ft_strcat.o ft_strcpy.o ft_strncat.o ft_strrchr.o ft_isalpha.o ft_memccpy.o ft_strchr.o ft_strdup.o ft_strncmp.o ft_strstr.o ft_atoi.o ft_isascii.o ft_memcpy.o ft_strclr.o ft_strlcat.o ft_strncpy.o ft_tolower.o ft_memmove.o ft_memchr.o ft_memcmp.o
ranlib libft.a
make[1]: Leaving directory `/home/username/libft'
\033[38;5;46m cp ../libft/libft.a assets/ \033[31m
make[1]: Entering directory `/home/username/libft'
make[1]: *** No rule to make target `so'. Stop.
make[1]: Leaving directory `/home/username/libft'
make: *** [libft.so] Error 2
In linux the usage is a bit more complicated, i'll add it to the readme. This unit-test needs the dynamic version of a libft to run, in macOS it's easy to turn a static library into a dynamic one, but it's not possible on linux unless obj file are compiled with -fPIC. So you need to add a rule called 'so' in the Makefile of your libft to create a dynamic library instead of static (your dynamic library must be called "libft.so").
i've added rule "so" to my Makefile, it looks like:
so:
$(CC) -fPIC $(CFLAGS) $(SRC)
gcc -shared -o libft.so $(BIN)
while trying to make re
i think i found some small mistakes - there were ";" in rule SONAME:
$ git diff Makefile
...
@@ -80,7 +80,7 @@ RUN_COLOR = 147
## AUTO ##
#################
-SHELL = /bin/zsh
+SHELL = /bin/bash
OBJ = $(addprefix $(OBJDIR)/, $(addsuffix .o, $(basename $(SRC))))
INCFLAG = $(addprefix -I,$(INCDIR))
NORME = $(addsuffix /*.h,$(INCDIR)) $(addprefix $(SRCDIR)/,$(SRC))
@@ -141,12 +141,12 @@ $(SONAME):
else
$(SONAME):
@make -C $(LIBFTDIR) so
- @if [ -e $(LIBFTDIR)/libft.so ]; \
- then; \
+ @if [ -e $(LIBFTDIR)/libft.so ];\
+ then\
cp $(LIBFTDIR)/libft.so . ;\
- else;\
- echo Please provide a libft.so in the directory $(shell pwd); \
- fi;
+ else\
+ echo Please provide a libft.so in the directory $(shell pwd);\
+ fi
endif
$(WRAPNAME): $(ASSETDIR)/wrapper.c
@@ -159,7 +159,7 @@ $(ASSETDIR)/$(ANAME):
@rm -f $(SONAME)
@$(call exec_color, "\033[38;5;$(LINK_COLOR_T)m", make -C "$(LIBFTDIR)")
@$(call exec_color, "\033[38;5;$(LINK_COLOR_T)m", cp "$(LIBFTDIR)/libft.a" $(ASSETDIR)/)
-
+
# Linking
$(ASSETDIR)/$(NAME): $(OBJ)
@$(call disp_title,Linking,$(LINK_COLOR_T));
when i deleted those i got next error
(it doesn't like #include <bsd/string.h>
in ./include/libft_test.h):
In file included from src/main.c:21:
./include/libft_test.h:31:12: fatal error: 'bsd/string.h' file not found
# include <bsd/string.h>
^
1 error generated.
make: *** [obj/main.o] Error 1
I've searched google and found answer that i have to install package (for ubuntu):
sudo apt-get install libbsd-dev
then i finally was able to run your superb tests =) so plz add also this info to description btw your tests are saving a lot of time for people in our cluster (in Kiyv)! but making us lazy =( and if i remember correctly we found some cases that might be added to this test - i'll write you if i find out that cases
also it is interesting if your test could run on 32-bit machine?
when trying to compile it on my 32-bit Ubuntu
Linux computer2name 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:31:42 UTC 2014 i686 i686 i686 GNU/Linux
i get
./include/libft_test.h:98:2: error: size of anonymous bit-field (48 bits) exceeds size of its type (32 bits)
long :48;
if i try to set it to 32 i get
src/display_test_result.c:195:49: error: format specifies type 'unsigned long' but the argument has type 'unsigned long long' [-Werror,-Wformat]
current_fun_name, vdiff, speeder, opponent, TIME_DIFF_LIB, TIME_DIFF_SYS);
^~~~~~~~~~~~~
./include/libft_test.h:232:25: note: expanded from macro 'TIME_DIFF_LIB'
# define TIME_DIFF_LIB (g_time.mid - g_time.begin)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/display_test_result.c:195:64: error: format specifies type 'unsigned long' but the argument has type 'unsigned long long' [-Werror,-Wformat]
current_fun_name, vdiff, speeder, opponent, TIME_DIFF_LIB, TIME_DIFF_SYS);
^~~~~~~~~~~~~
./include/libft_test.h:231:25: note: expanded from macro 'TIME_DIFF_SYS'
# define TIME_DIFF_SYS (g_time.end - g_time.mid)
^~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
thanks for your report, i've fixed the readme and removed the shell forced to zsh. i've also merged the linux and master branch and fixed the compilation for 32bit but i still don't know if it works on 32bit machines.
Hi alelievr have been trying to configure your unit test on my Ubuntu Linux machine but I'm failing. Could you please provide a detailed process on how to use your unit test on Linux.
I'm using Ubuntu 20.04, and i still got the same error.
uname -a Linux limitless-GE70-2PC 5.4.0-52-generic #57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
gcc --version gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc.
clang --version clang (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc.
I've installed the right libraries, symlinked my gcc to clang, added the so rule, but it still gives the same error:
[ Building #0 ]
➤ gcc -O2 -funroll-loops -Werror -Wall -Wextra -I./include -o obj/src/main.o -c src/main.c
In file included from src/main.c:21:
src/main.c: In function ‘run_subtests’:
./include/libft_test.h:238:54: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
238 | # define RESET_DIFF lseek(g_diff_fd, 0, SEEK_SET); write(g_diff_fd, "\0", 1);
| ^~~~~~~~~
src/main.c:147:3: note: in expansion of macro ‘RESET_DIFF’
147 | RESET_DIFF;
| ^~~~~~
src/main.c: In function ‘run_subbench’:
./include/libft_test.h:238:54: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
238 | # define RESET_DIFF lseek(g_diff_fd, 0, SEEK_SET); write(g_diff_fd, "\0", 1);
| ^~~~~~~~~
src/main.c:172:3: note: in expansion of macro ‘RESET_DIFF’
172 | RESET_DIFF;
| ^~~~~~
src/main.c: In function ‘main’:
src/main.c:282:2: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
282 | write(fd, &g_shared_mem, 8);
| ^~~~~~~
In file included from src/main.c:21:
./include/libft_test.h:238:54: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
238 | # define RESET_DIFF lseek(g_diff_fd, 0, SEEK_SET); write(g_diff_fd, "\0", 1);
| ^~~~~~~~~
src/main.c:289:2: note: in expansion of macro ‘RESET_DIFF’
289 | RESET_DIFF;
| ^~~~~~
cc1: all warnings being treated as errors
make: [Makefile:193: obj/src/main.o] Error 1
[libft-unit-tests]$ make
[ Building #0 ]
➤ clang -O2 -funroll-loops -Werror -Wall -Wextra -I./include -o obj/src/main.o -c src/main.c
In file included from src/main.c:21:
src/main.c: In function ‘run_subtests’:
./include/libft_test.h:238:54: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
238 | # define RESET_DIFF lseek(g_diff_fd, 0, SEEK_SET); write(g_diff_fd, "\0", 1);
| ^~~~~~~~~
src/main.c:147:3: note: in expansion of macro ‘RESET_DIFF’
147 | RESET_DIFF;
| ^~~~~~
src/main.c: In function ‘run_subbench’:
./include/libft_test.h:238:54: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
238 | # define RESET_DIFF lseek(g_diff_fd, 0, SEEK_SET); write(g_diff_fd, "\0", 1);
| ^~~~~~~~~
src/main.c:172:3: note: in expansion of macro ‘RESET_DIFF’
172 | RESET_DIFF;
| ^~~~~~
src/main.c: In function ‘main’:
src/main.c:282:2: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
282 | write(fd, &g_shared_mem, 8);
| ^~~~~~~
In file included from src/main.c:21:
./include/libft_test.h:238:54: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
238 | # define RESET_DIFF lseek(g_diff_fd, 0, SEEK_SET); write(g_diff_fd, "\0", 1);
| ^~~~~~~~~
src/main.c:289:2: note: in expansion of macro ‘RESET_DIFF’
289 | RESET_DIFF;
| ^~~~~~
cc1: all warnings being treated as errors
make: [Makefile:193: obj/src/main.o] Error 1
i'm trying to run test on this system:
i've have right structure of files&folders (already run tests on mac, wanted to test at home) i've tried to make sudo chmod 777 -R for both folders i've tried to run make re with sudo gcc is:
clang version:
but i'm getting next error (i've added -v flag to CSOFLAGS):