Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
new uname test
  • Loading branch information
tnut committed Apr 26, 2024
1 parent e4914d7 commit 6824c2a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,32 @@

include ../Makefile.inc

all: test1 test2 list1
all: uname test1 test2 list1

uname:
$(CXX) -DNDEBUG -std=c++11 -O2 -Werror -pedantic -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -c -o $@.o $@.cxx
$(CXX) $@.o -o $@ -L"../src" -lcards -lcurl -larchive
rm $@.o

test1:
$(CXX) -DNDEBUG -std=c++11 -O2 -Werror -pedantic -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -c -o test1.o test1.cxx
$(CXX) test1.o -o $@ -L"../src" -lcards -lcurl -larchive
rm test1.o
$(CXX) -DNDEBUG -std=c++11 -O2 -Werror -pedantic -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -c -o $@.o $@.cxx
$(CXX) $@.o -o $@ -L"../src" -lcards -lcurl -larchive
rm $@.o

test2:
$(CXX) -DNDEBUG -std=c++11 -O2 -Werror -pedantic -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -c -o test2.o test2.cxx
$(CXX) test2.o -o $@ -L"../src" -lcards -lcurl -larchive
rm test2.o
$(CXX) -DNDEBUG -std=c++11 -O2 -Werror -pedantic -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -c -o $@.o $@.cxx
$(CXX) $@.o -o $@ -L"../src" -lcards -lcurl -larchive
rm $@.o

list1:
$(CXX) -DNDEBUG -std=c++11 -O2 -Werror -pedantic -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -c -o list1.o list1.cxx
$(CXX) list1.o -o $@ -L"../src" -lcards -lcurl -larchive
rm list1.o
$(CXX) -DNDEBUG -std=c++11 -O2 -Werror -pedantic -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -c -o $@.o $@.cxx
$(CXX) $@.o -o $@ -L"../src" -lcards -lcurl -larchive
rm $@.o

clean:
rm -f list1
rm -f test1
rm -f test2
rm -f uname

# End of file
26 changes: 26 additions & 0 deletions tests/uname.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <sys/utsname.h>
#include <cstdio>
#include <cstdlib>

int main()
{
int i = 1;
struct utsname *buf=(utsname*)malloc(sizeof (utsname));
if(!buf)
return i;
i = uname(buf);
if (i)
return i;
printf("1. Machine Hardware: %s\n", buf->machine);
printf("2. Hostname: %s\n", buf->nodename);
printf("3. OS name: %s\n", buf->sysname);
printf("4. Kernel Release: %s\n", buf->release);
printf("5. Kernel Version: %s\n", buf->version);
printf("6. Domain name: %s\n", buf->domainname);
printf("-> Size of utsname->Version: %u\n",sizeof (buf->version));
printf("-> 6 x %u is the size of utsname: %u\n",
sizeof (buf->version),
sizeof (utsname));
free(buf);
return i;
}

0 comments on commit 6824c2a

Please sign in to comment.