libcody: Remove testsuite [PR 98318]

libcody's testsuite is not very portable, and is testing a host
library, so will do weird things on cross compiling, I think.  Let's
just drop it.

	libcody/
	* Makefile.in (LDFLAGS): Drop -L..
	* tests/01-serialize/connect.cc: Delete.
	* tests/01-serialize/decoder.cc: Delete.
	* tests/01-serialize/encoder.cc: Delete.
	* tests/02-comms/client-1.cc: Delete.
	* tests/02-comms/pivot-1.cc: Delete.
	* tests/02-comms/server-1.cc: Delete.
	* tests/Makesub.in: Delete.
	* tests/jouster: Delete.
This commit is contained in:
Nathan Sidwell 2020-12-23 08:04:52 -08:00
parent c142ae5e17
commit 16929214fd
9 changed files with 1 additions and 440 deletions

View File

@ -100,7 +100,7 @@ endif
CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
# Linker options
LDFLAGS := -L. @LDFLAGS@
LDFLAGS := @LDFLAGS@
LIBS := @LIBS@
# Per-source & per-directory compile flags (warning: recursive)

View File

@ -1,30 +0,0 @@
// Test client connection handshake
// RUN: <<HELLO 1 TESTING
// RUN: $subdir$stem | ezio -p OUT $test |& ezio -p ERR $test
// RUN-END:
// OUT-NEXT:^HELLO {:[0-9]+} TEST IDENT$
// OUT-NEXT:$EOF
// ERR-NEXT:Code:{:[0-9]+}$
// ERR-NEXT:Version:1$
// ERR-NEXT:$EOF
// Cody
#include "cody.hh"
// C++
#include <iostream>
using namespace Cody;
int main (int, char *[])
{
Client client (0, 1);
auto token = client.Connect ("TEST", "IDENT");
std::cerr << "Code:" << token.GetCode () << '\n';
std::cerr << "Version:" << token.GetInteger () << '\n';
}

View File

@ -1,73 +0,0 @@
// CODYlib -*- mode:c++ -*-
// Copyright (C) 2020 Nathan Sidwell, nathan@acm.org
// License: Apache v2.0
// RUN: <<bob 'frob dob''\nF\_b\20\61\\'
// RUN: $subdir$stem |& ezio $test
// CHECK-NEXT: ^line:0 word:0 'bob'
// CHECK-NEXT: ^line:0 word:1 'frob dob$
// CHECK-OPTION: matchSpace
// CHECK-NEXT: ^F b a\'$
// CHECK-NEXT: $EOF
/* RUN: <<line-1 word:1 ;
RUN: <<'line 2' ;
RUN: <<
*/
// RUN: $subdir$stem |& ezio -p CHECK2 $test
// CHECK2-NEXT: line:0 word:0 'line-1'
// CHECK2-NEXT: line:0 word:1 'word:1'
// CHECK2-NEXT: line:1 word:0 'line 2'
// CHECK2-NEXT: error:No
// CHECK2-NEXT: $EOF
// RUN: <<'
// RUN: $subdir$stem |& ezio -p CHECK3 $test
// CHECK3-NEXT: error:Invalid argument
// CHECK3-NEXT: line:0 word:0 '''
// CHECK3-NEXT: $EOF
/* RUN: << ;
RUN: <<'\g'
*/
// RUN: $subdir$stem |& ezio -p CHECK4 $test
// CHECK4-NEXT: error:No
// CHECK4-NEXT: error:Invalid argument
// CHECK4-NEXT: line:1 word:0 ''\g''
// CHECK4-NEXT: $EOF
// RUN-END:
// Cody
#include "cody.hh"
// C++
#include <iostream>
// C
#include <cstring>
using namespace Cody;
int main (int, char *[])
{
Detail::MessageBuffer reader;
reader.PrepareToRead ();
while (int e = reader.Read (0))
if (e != EAGAIN && e != EINTR)
break;
std::vector<std::string> words;
for (unsigned line = 0; !reader.IsAtEnd (); line++)
{
if (int e = reader.Lex (words))
std::cerr << "error:" << strerror (e) << '\n';
for (unsigned ix = 0; ix != words.size (); ix++)
{
auto &word = words[ix];
std::cerr << "line:" << line << " word:" << ix
<< " '" << word << "'\n";
}
}
return 0;
}

View File

@ -1,48 +0,0 @@
// CODYlib -*- mode:c++ -*-
// Copyright (C) 2020 Nathan Sidwell, nathan@acm.org
// License: Apache v2.0
// Test message encoding, both string quoting and continuation lines
// RUN: $subdir$stem |& ezio $test
// RUN-END:
// The ¯ is utf8-encoded as c2 af
// CHECK-NEXT: ^bob 'frob dob''\n¯\\'$
// CHECK-NEXT: ^2 ;$
// CHECK-NEXT: ^3$
// CHECK-NEXT: $EOF
// Cody
#include "cody.hh"
using namespace Cody;
int main (int, char *[])
{
Detail::MessageBuffer writer;
writer.BeginLine ();
writer.AppendWord ("bob");
writer.AppendWord ("frob dob", true);
writer.Append ("\n\xc2\xaf\\", true);
writer.EndLine ();
writer.PrepareToWrite ();
while (int err = writer.Write (2))
if (err != EAGAIN && err != EINTR)
break;
writer.BeginLine ();
writer.Append ("2", true);
writer.EndLine ();
writer.BeginLine ();
writer.Append ("3", true);
writer.EndLine ();
writer.PrepareToWrite ();
while (int err = writer.Write (2))
if (err != EAGAIN && err != EINTR)
break;
return 0;
}

View File

@ -1,97 +0,0 @@
// Test client message round tripping
/*
RUN: <<HELLO 1 TESTING ;
RUN: <<PATHNAME REPO ;
RUN: <<PATHNAME biz/bar ;
RUN: <<PATHNAME blob ;
RUN: <<BOOL FALSE ;
RUN: << BOOL TRUE ;
RUN: << PATHNAME foo ;
RUN: <<OK
*/
// RUN: $subdir$stem | ezio -p OUT $test |& ezio -p ERR $test
// RUN-END:
/*
OUT-NEXT:^HELLO {:[0-9]+} TEST IDENT ;$
OUT-NEXT:^MODULE-REPO ;
OUT-NEXT:^MODULE-EXPORT bar ;
OUT-NEXT:^MODULE-IMPORT foo ;
OUT-NEXT:^INCLUDE-TRANSLATE baz.frob ;
OUT-NEXT:^INCLUDE-TRANSLATE ./corge ;
OUT-NEXT:^INCLUDE-TRANSLATE ./quux ;
OUT-NEXT:^MODULE-COMPILED bar
*/
// OUT-NEXT:$EOF
// ERR-NEXT:Code:1$
// ERR-NEXT:Integer:1$
// ERR-NEXT:Code:5$
// ERR-NEXT:String:REPO$
// ERR-NEXT:Code:5$
// ERR-NEXT:String:biz/bar$
// ERR-NEXT:Code:5$
// ERR-NEXT:String:blob$
// ERR-NEXT:Code:4$
// ERR-NEXT:Integer:0$
// ERR-NEXT:Code:4$
// ERR-NEXT:Integer:1$
// ERR-NEXT:Code:5$
// ERR-NEXT:String:foo
// ERR-NEXT:Code:3$
// ERR-NEXT:Integer:
// ERR-NEXT:$EOF
// Cody
#include "cody.hh"
// C++
#include <iostream>
using namespace Cody;
int main (int, char *[])
{
Client client (0, 1);
client.Cork ();
if (client.Connect ("TEST", "IDENT").GetCode () != Client::PC_CORKED)
std::cerr << "Not corked!\n";
if (client.ModuleRepo ().GetCode () != Client::PC_CORKED)
std::cerr << "Not corked!\n";
if (client.ModuleExport ("bar").GetCode () != Client::PC_CORKED)
std::cerr << "Not corked!\n";
if (client.ModuleImport ("foo").GetCode () != Client::PC_CORKED)
std::cerr << "Not corked!\n";
if (client.IncludeTranslate ("baz.frob").GetCode () != Client::PC_CORKED)
std::cerr << "Not corked!\n";
if (client.IncludeTranslate ("./corge").GetCode () != Client::PC_CORKED)
std::cerr << "Not corked!\n";
if (client.IncludeTranslate ("./quux").GetCode () != Client::PC_CORKED)
std::cerr << "Not corked!\n";
if (client.ModuleCompiled ("bar").GetCode () != Client::PC_CORKED)
std::cerr << "Not corked!\n";
auto result = client.Uncork ();
for (auto iter = result.begin (); iter != result.end (); ++iter)
{
std::cerr << "Code:" << iter->GetCode () << '\n';
switch (iter->GetCategory ())
{
case Packet::INTEGER:
std::cerr << "Integer:" << iter->GetInteger () << '\n';
break;
case Packet::STRING:
std::cerr << "String:" << iter->GetString () << '\n';
break;
case Packet::VECTOR:
{
auto const &v = iter->GetVector ();
for (unsigned ix = 0; ix != v.size (); ix++)
std::cerr << "Vector[" << ix << "]:" << v[ix] << '\n';
}
break;
}
}
}

View File

@ -1,76 +0,0 @@
// Test resolver pivot
// RUN:<<HELLO 1 TEST IDENT ;
// RUN:<<MODULE-REPO ;
// RUN:<<HELLO 1 TEST IDENT
// RUN: $subdir$stem | ezio -p OUT1 $test |& ezio -p ERR1 $test
// OUT1-NEXT:HELLO 1 default ;
// OUT1-NEXT:PATHNAME cmi.cache ;
// OUT1-NEXT:ERROR 'already connected
// OUT1-NEXT:$EOF
// ERR1-NEXT:resolver is handler
// ERR1-NEXT:$EOF
// RUN:<<MODULE-REPO ;
// RUN:<<HELLO 1 TEST IDENT ;
// RUN:<<MODULE-REPO
// RUN: $subdir$stem | ezio -p OUT2 $test |& ezio -p ERR2 $test
// OUT2-NEXT:ERROR 'not connected
// OUT2-NEXT:HELLO 1 default ;
// OUT2-NEXT:PATHNAME cmi.cache
// OUT2-NEXT:$EOF
// ERR2-NEXT:resolver is handler
// ERR2-NEXT:$EOF
// RUN-END:
#include "cody.hh"
#include <iostream>
using namespace Cody;
class Handler : public Resolver
{
virtual Handler *ConnectRequest (Server *s, unsigned ,
std::string &, std::string &)
{
ErrorResponse (s, "unexpected connect call");
return nullptr;
}
};
Handler handler;
class Initial : public Resolver
{
virtual Handler *ConnectRequest (Server *s, unsigned v,
std::string &agent, std::string &ident)
{
Resolver::ConnectRequest (s, v, agent, ident);
return &handler;
}
};
Initial initial;
int main (int, char *[])
{
Server server (&initial, 0, 1);
while (int e = server.Read ())
if (e != EAGAIN && e != EINTR)
break;
server.ProcessRequests ();
if (server.GetResolver () == &handler)
std::cerr << "resolver is handler\n";
else if (server.GetResolver () == &initial)
std::cerr << "resolver is initial\n";
else
std::cerr << "resolver is surprising\n";
server.PrepareToWrite ();
while (int e = server.Write ())
if (e != EAGAIN && e != EINTR)
break;
}

View File

@ -1,68 +0,0 @@
// Test server message round tripping
/*
RUN:<<HELLO 1 TEST IDENT ;
RUN:<<MODULE-REPO ;
RUN:<<MODULE-EXPORT bar ;
RUN:<<MODULE-IMPORT foo ;
RUN:<<NOT A COMMAND ;
RUN:<<INCLUDE-TRANSLATE baz.frob ;
RUN:<<INCLUDE-TRANSLATE ./quux ;
RUN:<<MODULE-COMPILED bar ;
RUN:<<MODULE-IMPORT ''
*/
// RUN: $subdir$stem | ezio -p OUT1 $test |& ezio -p ERR1 $test
// These all fail because there's nothing in the server interpretting stuff
/*
OUT1-NEXT: ^HELLO 1 default ;
OUT1-NEXT: ^PATHNAME cmi.cache ;
OUT1-NEXT: ^PATHNAME bar.cmi ;
OUT1-NEXT: ^PATHNAME foo.cmi ;
OUT1-NEXT: ^ERROR 'unrecognized \'NOT
OUT1-NEXT: ^BOOL FALSE ;
OUT1-NEXT: ^BOOL FALSE ;
OUT1-NEXT: ^OK
OUT1-NEXT: ^ERROR 'malformed
*/
// OUT1-NEXT:$EOF
// ERR1-NEXT:$EOF
/*
RUN:<<HELLO 1 TEST IDENT
RUN:<<MODULE-REPO
*/
// RUN: $subdir$stem | ezio -p OUT2 $test |& ezio -p ERR2 $test
/*
OUT2-NEXT: ^HELLO 1 default
*/
// OUT2-NEXT:$EOF
// ERR2-NEXT:$EOF
// RUN-END:
// Cody
#include "cody.hh"
// C++
#include <iostream>
using namespace Cody;
int main (int, char *[])
{
Resolver r;
Server server (&r, 0, 1);
while (int e = server.Read ())
if (e != EAGAIN && e != EINTR)
break;
server.ProcessRequests ();
if (server.GetResolver () != &r)
std::cerr << "resolver changed\n";
server.PrepareToWrite ();
while (int e = server.Write ())
if (e != EAGAIN && e != EINTR)
break;
}

View File

@ -1,36 +0,0 @@
# CODYlib -*- mode:Makefile -*-
# Copyright (C) 2019-2020 Nathan Sidwell, nathan@acm.org
# License: Apache v2.0
ALOY := @ALOY@
TESTS := $(patsubst $(srcdir)/%.cc,%,\
$(wildcard $(srcdir)/tests/*/*.cc))
TESTDIRS = $(shell cd $(srcdir)/${<D} ; echo *(/))
testdir := $(and $(filter-out /%,$(srcdir)),../)$(srcdir)/tests
check:: tests/cody.defs $(TESTS)
+cd ${<D} && srcbuilddir=$(srcdir)/tests JOUST=${<F} \
$(ALOY) -t kratos -o cody -g $(testdir)/jouster $(TESTDIRS)
ifeq ($(firstword $(aloy)),:)
@echo WARNING: tests were not run as Joust test harness was not found
endif
tests/cody.defs: tests/Makesub
echo '# Automatically generated by Make' >$@
echo 'testdir=$(testdir)' >>$@
echo 'timelimit=60' >>$@
echo 'memlimit=1' >>$@
echo 'cpulimit=60' >>$@
echo 'filelimit=1' >>$@
echo 'SHELL=$(SHELL)' >>$@
$(TESTS): %: %.o libcody.a
$(CXX) $(LDFLAGS) $< -lcody $(LIBS) -o $@
clean::
rm -f $(TESTS)
rm -f $(TESTS:=.o) $(TESTS:=.d)
ifeq ($(filter clean%,$(MAKECMDGOALS)),)
-include $(TESTS:=.d)
endif

View File

@ -1,11 +0,0 @@
#! /bin/zsh
# CODYlib -*- mode:Makefile -*-
# Copyright (C) 2019-2020 Nathan Sidwell, nathan@acm.org
# License Apache v2.0
pushd ${0%/*}
setopt nullglob
for subdir in $@ ; do
echo $subdir/*(.^*)
done
popd