Convert regress to C.

This commit is contained in:
Jonas 'Sortie' Termansen 2016-02-28 23:18:13 +01:00
parent 9ea3edf36f
commit 8d58033846
11 changed files with 31 additions and 21 deletions

2
regress/.gitignore vendored
View File

@ -1,3 +1,3 @@
regress regress
test-* test-*
!test-*.c++ !test-*.c

View File

@ -5,11 +5,11 @@ include ../build-aux/version.mak
include ../build-aux/dirs.mak include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL) OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL) CFLAGS?=$(OPTLEVEL)
TESTDIR?=$(LIBEXECDIR)/test TESTDIR?=$(LIBEXECDIR)/test
CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\" -DTESTDIR=\"$(TESTDIR)\" CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\" -DTESTDIR=\"$(TESTDIR)\"
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti CFLAGS:=$(CFLAGS) -Wall -Wextra
BINARIES:=\ BINARIES:=\
regress \ regress \
@ -36,8 +36,8 @@ ifneq ($(TESTS),)
install $(TESTS) $(DESTDIR)$(TESTDIR) install $(TESTS) $(DESTDIR)$(TESTDIR)
endif endif
%: %.c++ %: %.c
$(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@
clean: clean:
rm -f $(BINARIES) $(TESTS) *.o rm -f $(BINARIES) $(TESTS) *.o

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
regress.c++ regress.c
Automatically invokes system tests. Automatically invokes system tests.
*******************************************************************************/ *******************************************************************************/
@ -26,6 +26,7 @@
#include <errno.h> #include <errno.h>
#include <error.h> #include <error.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -48,7 +49,7 @@ bool is_usable_terminal(int fd)
10 <= ws.ws_col; 10 <= ws.ws_col;
} }
void tenth_last_column() void tenth_last_column(void)
{ {
struct wincurpos wcp; struct wincurpos wcp;
struct winsize ws; struct winsize ws;
@ -153,7 +154,8 @@ int main(int argc, char* argv[])
break; break;
if ( arg[1] != '-' ) if ( arg[1] != '-' )
{ {
while ( char c = *++arg ) switch ( c ) char c;
while ( (c = *++arg) ) switch ( c )
{ {
case 'b': buffered = true; break; case 'b': buffered = true; break;
case 'q': verbosity--; break; case 'q': verbosity--; break;

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
test-fmemopen.c++ test-fmemopen.c
Tests basic fmemopen() usage. Tests basic fmemopen() usage.
*******************************************************************************/ *******************************************************************************/

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
test-pthread-argv.c++ test-pthread-argv.c
Tests if the argument vector and environment dies with the main thread. Tests if the argument vector and environment dies with the main thread.
*******************************************************************************/ *******************************************************************************/
@ -31,8 +31,10 @@ char** global_argv;
char** global_envp; char** global_envp;
size_t answer = 0; size_t answer = 0;
void* thread_routine(void*) void* thread_routine(void* ctx)
{ {
(void) ctx;
int errnum; int errnum;
if ( (errnum = pthread_join(main_thread, NULL)) ) if ( (errnum = pthread_join(main_thread, NULL)) )
@ -49,8 +51,10 @@ void* thread_routine(void*)
exit(0); exit(0);
} }
int main(int /*argc*/, char* argv[], char* envp[]) int main(int argc, char* argv[], char* envp[])
{ {
(void) argc;
int errnum; int errnum;
for ( int i = 0; argv[i]; i++ ) for ( int i = 0; argv[i]; i++ )

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
test-pthread-basic.c++ test-pthread-basic.c
Tests whether basic pthread support works. Tests whether basic pthread support works.
*******************************************************************************/ *******************************************************************************/

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
test-pthread-main-join.c++ test-pthread-main-join.c
Tests whether the main thread can be joined. Tests whether the main thread can be joined.
*******************************************************************************/ *******************************************************************************/

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
test-pthread-once.c++ test-pthread-once.c
Tests whether basic pthread_once() support works. Tests whether basic pthread_once() support works.
*******************************************************************************/ *******************************************************************************/
@ -27,13 +27,15 @@
static int init_counter = 0; static int init_counter = 0;
static pthread_once_t init_counter_once = PTHREAD_ONCE_INIT; static pthread_once_t init_counter_once = PTHREAD_ONCE_INIT;
void init_counter_increase() void init_counter_increase(void)
{ {
init_counter++; init_counter++;
} }
void* thread_routine(void*) void* thread_routine(void* ctx)
{ {
(void) ctx;
pthread_once(&init_counter_once, init_counter_increase); pthread_once(&init_counter_once, init_counter_increase);
return NULL; return NULL;

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
test-pthread-self.c++ test-pthread-self.c
Tests whether basic pthread_self() support works. Tests whether basic pthread_self() support works.
*******************************************************************************/ *******************************************************************************/

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
test-pthread-tls.c++ test-pthread-tls.c
Tests whether basic tls support works. Tests whether basic tls support works.
*******************************************************************************/ *******************************************************************************/
@ -26,8 +26,10 @@
__thread int tls_variable = 42; __thread int tls_variable = 42;
void* thread_routine(void*) void* thread_routine(void* ctx)
{ {
(void) ctx;
test_assert(tls_variable == 42); test_assert(tls_variable == 42);
tls_variable = 9001; tls_variable = 9001;

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. this program. If not, see <http://www.gnu.org/licenses/>.
test-signal-raise.c++ test-signal-raise.c
Tests whether basic raise() support works. Tests whether basic raise() support works.
*******************************************************************************/ *******************************************************************************/