[asterisk-commits] mnicholson: branch mnicholson/asttest r167240 - in /team/mnicholson/asttest/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 5 11:59:43 CST 2009


Author: mnicholson
Date: Mon Jan  5 11:59:42 2009
New Revision: 167240

URL: http://svn.digium.com/view/asterisk?view=rev&rev=167240
Log:
Split the ts functions into their own files.

 * asttest/asttest.c: split ts_* functions into include/asttest/testsuite.h and
 lib/testsuite.c
 * asttest/Makefile: updated to build lib/testsuite.c
 * asttest/lib/testsuite.c: added, split from asttest.c
 * asttest/include/asttest/testsuite.h: added, split from asttest.c

Added:
    team/mnicholson/asttest/asttest/include/
    team/mnicholson/asttest/asttest/include/asttest/
    team/mnicholson/asttest/asttest/include/asttest/testsuite.h   (with props)
    team/mnicholson/asttest/asttest/lib/
    team/mnicholson/asttest/asttest/lib/testsuite.c   (with props)
Modified:
    team/mnicholson/asttest/asttest/Makefile
    team/mnicholson/asttest/asttest/asttest.c

Modified: team/mnicholson/asttest/asttest/Makefile
URL: http://svn.digium.com/view/asterisk/team/mnicholson/asttest/asttest/Makefile?view=diff&rev=167240&r1=167239&r2=167240
==============================================================================
--- team/mnicholson/asttest/asttest/Makefile (original)
+++ team/mnicholson/asttest/asttest/Makefile Mon Jan  5 11:59:42 2009
@@ -21,8 +21,8 @@
 .PHONY: clean dist-clean distclean test check asterisk
 
 # Basic set of sources and flags/libraries/includes
-OBJS:=asttest.o
-CFLAGS:=-g -c -D_GNU_SOURCE -Wall -I/usr/include/lua5.1
+OBJS:=asttest.o lib/testsuite.o
+CFLAGS:=-g -c -D_GNU_SOURCE -Wall -I/usr/include/lua5.1 -Iinclude
 T_LIBS:=-llua5.1
 
 AST_INSTALL_DIR = $(PWD)/asterisk

Modified: team/mnicholson/asttest/asttest/asttest.c
URL: http://svn.digium.com/view/asterisk/team/mnicholson/asttest/asttest/asttest.c?view=diff&rev=167240&r1=167239&r2=167240
==============================================================================
--- team/mnicholson/asttest/asttest/asttest.c (original)
+++ team/mnicholson/asttest/asttest/asttest.c Mon Jan  5 11:59:42 2009
@@ -31,86 +31,8 @@
 #include <lauxlib.h>
 #include <lualib.h>
 
-struct test_suite {
-	unsigned int pass;
-	unsigned int fail;
-	unsigned int xfail;
-	unsigned int skip;
-	unsigned int total;
-	FILE *log;
-};
-
-int ts_init(struct test_suite *ts, const char *log_file_path) {
-	memset(ts, 0, sizeof(struct test_suite));
-
-	ts->log = fopen(log_file_path, "w");
-	if (!ts->log) {
-		fprintf(stderr, "Error log file (%s): %s\n", log_file_path, strerror(errno));
-		return 1;
-	}
-
-	return 0;
-}
-
-void ts_cleanup(struct test_suite *ts) {
-	if (ts->log) {
-		fclose(ts->log);
-	}
-}
-
-void ts_print(struct test_suite *ts) {
-	printf("Test results:\n");
-	printf("  tests passed:      %d\n", ts->pass);
-	printf("  test failures:     %d\n", ts->fail);
-	printf("  expected failures: %d\n", ts->xfail);
-	printf("  tests skipped:     %d\n", ts->skip);
-	printf("\n");
-	printf("Total test run:      %d\n", ts->total);
-}
-
-int ts_log_va(struct test_suite *ts, const char *test_name, const char *fmt, va_list ap) {
-	int res;
-	res = fprintf(ts->log, "%s: ", test_name);
-	res += vfprintf(ts->log, fmt, ap);
-	return res;
-}
-
-int __attribute__((format(printf, 3, 4))) ts_log(struct test_suite *ts, const char *test_name, const char *fmt, ...) {
-	va_list ap;
-	int res;
-	va_start(ap, fmt);
-	res = ts_log_va(ts, test_name, fmt, ap);
-	va_end(ap);
-	return res;
-}
-
-void ts_pass(struct test_suite *ts, const char *test_name) {
-	ts->pass++;
-	ts->total++;
-	
-	ts_log(ts, test_name, "test passed\n");
-}
-
-void ts_fail(struct test_suite *ts, const char *test_name) {
-	ts->fail++;
-	ts->total++;
-	
-	ts_log(ts, test_name, "test failed\n");
-}
-
-void ts_xfail(struct test_suite *ts, const char *test_name) {
-	ts->xfail++;
-	ts->total++;
-
-	ts_log(ts, test_name, "expected failure\n");
-}
-
-void ts_skip(struct test_suite *ts, const char *test_name) {
-	ts->skip++;
-	ts->total++;
-
-	ts_log(ts, test_name, "test skipped\n");
-}
+#include "asttest/testsuite.h"
+
 
 /*
  * \brief Check if the given result string equals the string stored at the 

Added: team/mnicholson/asttest/asttest/include/asttest/testsuite.h
URL: http://svn.digium.com/view/asterisk/team/mnicholson/asttest/asttest/include/asttest/testsuite.h?view=auto&rev=167240
==============================================================================
--- team/mnicholson/asttest/asttest/include/asttest/testsuite.h (added)
+++ team/mnicholson/asttest/asttest/include/asttest/testsuite.h Mon Jan  5 11:59:42 2009
@@ -1,0 +1,44 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2008, Digium, Inc.
+ *
+ * Matthew Nichiolson <mnicholson at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+#ifndef ASTTEST_TESTSUITE_H
+#define ASTTEST_TESTSUITE_H
+
+struct test_suite {
+	unsigned int pass;
+	unsigned int fail;
+	unsigned int xfail;
+	unsigned int skip;
+	unsigned int total;
+	FILE *log;
+};
+
+int ts_init(struct test_suite *ts, const char *log_file_path);
+void ts_cleanup(struct test_suite *ts);
+
+void ts_print(struct test_suite *ts);
+
+int ts_log_va(struct test_suite *ts, const char *test_name, const char *fmt, va_list ap);
+int __attribute__((format(printf, 3, 4))) ts_log(struct test_suite *ts, const char *test_name, const char *fmt, ...);
+
+void ts_pass(struct test_suite *ts, const char *test_name);
+void ts_fail(struct test_suite *ts, const char *test_name);
+void ts_xfail(struct test_suite *ts, const char *test_name);
+void ts_skip(struct test_suite *ts, const char *test_name);
+
+#endif

Propchange: team/mnicholson/asttest/asttest/include/asttest/testsuite.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/include/asttest/testsuite.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/include/asttest/testsuite.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/mnicholson/asttest/asttest/lib/testsuite.c
URL: http://svn.digium.com/view/asterisk/team/mnicholson/asttest/asttest/lib/testsuite.c?view=auto&rev=167240
==============================================================================
--- team/mnicholson/asttest/asttest/lib/testsuite.c (added)
+++ team/mnicholson/asttest/asttest/lib/testsuite.c Mon Jan  5 11:59:42 2009
@@ -1,0 +1,98 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2008, Digium, Inc.
+ *
+ * Matthew Nichiolson <mnicholson at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "asttest/testsuite.h"
+
+int ts_init(struct test_suite *ts, const char *log_file_path) {
+	memset(ts, 0, sizeof(struct test_suite));
+
+	ts->log = fopen(log_file_path, "w");
+	if (!ts->log) {
+		fprintf(stderr, "Error log file (%s): %s\n", log_file_path, strerror(errno));
+		return 1;
+	}
+
+	return 0;
+}
+
+void ts_cleanup(struct test_suite *ts) {
+	if (ts->log) {
+		fclose(ts->log);
+	}
+}
+
+void ts_print(struct test_suite *ts) {
+	printf("Test results:\n");
+	printf("  tests passed:      %d\n", ts->pass);
+	printf("  test failures:     %d\n", ts->fail);
+	printf("  expected failures: %d\n", ts->xfail);
+	printf("  tests skipped:     %d\n", ts->skip);
+	printf("\n");
+	printf("Total test run:      %d\n", ts->total);
+}
+
+int ts_log_va(struct test_suite *ts, const char *test_name, const char *fmt, va_list ap) {
+	int res;
+	res = fprintf(ts->log, "%s: ", test_name);
+	res += vfprintf(ts->log, fmt, ap);
+	return res;
+}
+
+int __attribute__((format(printf, 3, 4))) ts_log(struct test_suite *ts, const char *test_name, const char *fmt, ...) {
+	va_list ap;
+	int res;
+	va_start(ap, fmt);
+	res = ts_log_va(ts, test_name, fmt, ap);
+	va_end(ap);
+	return res;
+}
+
+void ts_pass(struct test_suite *ts, const char *test_name) {
+	ts->pass++;
+	ts->total++;
+	
+	ts_log(ts, test_name, "test passed\n");
+}
+
+void ts_fail(struct test_suite *ts, const char *test_name) {
+	ts->fail++;
+	ts->total++;
+	
+	ts_log(ts, test_name, "test failed\n");
+}
+
+void ts_xfail(struct test_suite *ts, const char *test_name) {
+	ts->xfail++;
+	ts->total++;
+
+	ts_log(ts, test_name, "expected failure\n");
+}
+
+void ts_skip(struct test_suite *ts, const char *test_name) {
+	ts->skip++;
+	ts->total++;
+
+	ts_log(ts, test_name, "test skipped\n");
+}
+

Propchange: team/mnicholson/asttest/asttest/lib/testsuite.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mnicholson/asttest/asttest/lib/testsuite.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mnicholson/asttest/asttest/lib/testsuite.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list