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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Feb 1 13:36:59 CST 2009


Author: mnicholson
Date: Sun Feb  1 13:36:58 2009
New Revision: 172777

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=172777
Log:
added the -a option, which takes the path to the directory asterisk was
installed to.  It is roughly equivalent to the --prefix option at configure
time, with some exceptions.

Modified:
    team/mnicholson/asttest/asttest/asttest.c
    team/mnicholson/asttest/asttest/include/asttest/asttest.h
    team/mnicholson/asttest/asttest/include/asttest/testsuite.h
    team/mnicholson/asttest/asttest/lib/testsuite.c

Modified: team/mnicholson/asttest/asttest/asttest.c
URL: http://svn.digium.com/svn-view/asterisk/team/mnicholson/asttest/asttest/asttest.c?view=diff&rev=172777&r1=172776&r2=172777
==============================================================================
--- team/mnicholson/asttest/asttest/asttest.c (original)
+++ team/mnicholson/asttest/asttest/asttest.c Sun Feb  1 13:36:58 2009
@@ -295,13 +295,18 @@
 void usage(const char *prog_name) {
 	fprintf(stderr,
 		"Usage:\n"
-		"  %s [-wh] [-l <filename>] <test_dir> [test_dir...]\n"
+		"  %s [-wh] [-l <filename>] [-a <directory>] <test_dir> [test_dir...]\n"
 		"\n"
 		"Options:\n"
 		"  -l <filename>  Specify the name of the log file.  One log file will be\n"
 		"                 created for each test directory in that test directory\n"
 		"                 using the given name.  The default filename is\n"
 		"                 asttest.log.\n"
+		"  -a <directory> Specify the directory asterisk has been installed in.\n"
+		"                 This option is roughly equivalent to the value of\n"
+		"                 --prefix at configure time.  The actually asterisk binary\n"
+		"                 is expected to be located at <directory>/sbin/asterisk.\n"
+		"                 The default is 'asterisk'.\n"
 		"  -w             warn if tests were skipped because of errors.  This\n"
 		"                 option will cause a warning to print instead of an\n"
 		"                 error being generated if any tests fail because of\n"
@@ -331,15 +336,19 @@
 	/* set some default options */
 	opts->warn_on_error = 0;
 	opts->log_filename = default_log_filename;
+	opts->asterisk_path = "asterisk";
 
 	/* parse options */	
-	while ((c = getopt(argc, argv, "l:wh")) != -1) {
+	while ((c = getopt(argc, argv, "l:a:wh")) != -1) {
 		switch (c) {
 		case 'l':
 			opts->log_filename = optarg;
 			break;
 		case 'w':
 			opts->warn_on_error = 1;
+			break;
+		case 'a':
+			opts->asterisk_path = optarg;
 			break;
 		case 'h':
 			return 1;

Modified: team/mnicholson/asttest/asttest/include/asttest/asttest.h
URL: http://svn.digium.com/svn-view/asterisk/team/mnicholson/asttest/asttest/include/asttest/asttest.h?view=diff&rev=172777&r1=172776&r2=172777
==============================================================================
--- team/mnicholson/asttest/asttest/include/asttest/asttest.h (original)
+++ team/mnicholson/asttest/asttest/include/asttest/asttest.h Sun Feb  1 13:36:58 2009
@@ -24,9 +24,9 @@
 struct asttest_opts {
 	unsigned int warn_on_error:1;
 	const char *log_filename;
+	const char *asterisk_path;
 };
 
 extern const char *default_log_filename;
-extern char path_to_asttest[PATH_MAX];
 
 #endif

Modified: team/mnicholson/asttest/asttest/include/asttest/testsuite.h
URL: http://svn.digium.com/svn-view/asterisk/team/mnicholson/asttest/asttest/include/asttest/testsuite.h?view=diff&rev=172777&r1=172776&r2=172777
==============================================================================
--- team/mnicholson/asttest/asttest/include/asttest/testsuite.h (original)
+++ team/mnicholson/asttest/asttest/include/asttest/testsuite.h Sun Feb  1 13:36:58 2009
@@ -30,6 +30,7 @@
 	unsigned int error;
 	unsigned int total;
 	FILE *log;
+	char asterisk_path[PATH_MAX];
 };
 
 enum ts_result {

Modified: team/mnicholson/asttest/asttest/lib/testsuite.c
URL: http://svn.digium.com/svn-view/asterisk/team/mnicholson/asttest/asttest/lib/testsuite.c?view=diff&rev=172777&r1=172776&r2=172777
==============================================================================
--- team/mnicholson/asttest/asttest/lib/testsuite.c (original)
+++ team/mnicholson/asttest/asttest/lib/testsuite.c Sun Feb  1 13:36:58 2009
@@ -27,6 +27,7 @@
 
 int ts_init(struct testsuite *ts, const char *path, struct asttest_opts *opts) {
 	char log_path[PATH_MAX];
+	char cwd[PATH_MAX];
 	
 	memset(ts, 0, sizeof(struct testsuite));
 	
@@ -35,10 +36,28 @@
 	ts->log = fopen(log_path, "w");
 	if (!ts->log) {
 		fprintf(stderr, "Error opening log file for writing (%s): %s\n", log_path, strerror(errno));
-		return 1;
+		goto e_return;
+	}
+
+	/* make asterisk_path absolute */
+	if (opts->asterisk_path[0] == '/') {
+		/* path starts with '/' we will assume it is absolute */
+		snprintf(ts->asterisk_path, sizeof(ts->asterisk_path), "%s", opts->asterisk_path);
+	} else {
+		if (!getcwd(cwd, sizeof(cwd))) {
+			fprintf(stderr, "Error determining the current working directory\n");
+			goto e_close_log;
+		}
+
+		snprintf(ts->asterisk_path, sizeof(ts->asterisk_path), "%s/%s", cwd, opts->asterisk_path);
 	}
 
 	return 0;
+
+e_close_log:
+	fclose(ts->log);
+e_return:
+	return 1;
 }
 
 void ts_cleanup(struct testsuite *ts) {




More information about the asterisk-commits mailing list