Index: src/libbu/tests/bu_argv.c
===================================================================
--- src/libbu/tests/bu_argv.c	(revision 0)
+++ src/libbu/tests/bu_argv.c	(revision 0)
@@ -0,0 +1,260 @@
+/*                 T E S T _ A R G V . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2011-2012 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+
+#include "common.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "bu.h"
+
+/*
+ * Auxillary Tests (these piggyback on the main tests)
+ */
+/* Tests duplicating a argv array */
+int
+test_duplicate(int argc, char *argv[])
+{
+    char **result;
+    int pass = 1;
+    int i;
+
+    result = bu_dup_argv(argc, (const char **)argv);
+
+    if (result) {
+        for (i = 0; i < argc; i++) {
+            if (bu_strcmp(argv[i], result[i]) != 0)
+                pass = 0;
+        }
+
+        bu_free_argv(argc, result);
+    } else if (argc != 0) {
+        pass = 0;
+    }
+
+    return pass;
+}
+
+/* Tests inserting an array into itself in 3 different places */
+int
+test_insert(int argc, char *argv[])
+{
+    char **result;
+    int pass = 1;
+    int where;
+    int i = 0;
+    int j = 0;
+
+    /* Brute-force insert the string into itself everywhere. */
+    for (where = -1; where < (argc+2); where++) {
+        result = bu_dupinsert_argv(where, argc, (const char **)argv, argc, (const char **)argv);
+
+        if (where <= 0) {
+            /* Insert before */
+
+            for (i = 0; i < argc; i++)
+                if (bu_strcmp(argv[i], result[i]) != 0)
+                    pass = 0;
+
+            for (j = 0; j < argc; i++, j++)
+                if (bu_strcmp(argv[j], result[i]) != 0)
+                    pass = 0;
+
+        } else if (argc <= where) {
+            /* Insert after */
+
+            for (i = 0; i < argc; i++)
+                if (bu_strcmp(argv[i], result[i]) != 0)
+                    pass = 0;
+
+            for (j = 0; j < argc; i++, j++)
+                if (bu_strcmp(argv[j], result[i]) != 0)
+                    pass = 0;
+
+        } else {
+            /* Insert somewhere in the middle */
+
+            for (i = 0; i < where; i++)
+                if (bu_strcmp(argv[i], result[i]) != 0)
+                    pass = 0;
+
+            for (j = 0; j < argc; i++, j++)
+                if (bu_strcmp(argv[j], result[i]) != 0)
+                    pass = 0;
+
+            for (j = where; j < argc; i++, j++)
+                if (bu_strcmp(argv[j], result[i]) != 0)
+                    pass = 0;
+        }
+
+        bu_free_argv(argc + argc, result);
+    }
+
+    return pass;
+}
+
+/* Tests the bu_free_array - ensuring each item of the array is freed */
+int
+test_free(int argc, char *argv[])
+{
+    char **result;
+    int pass = 1;
+    int i;
+
+    result = bu_dup_argv(argc, (const char **)argv);
+    bu_free_array(argc, result, "test_free");
+
+    for (i = 0; i < argc; i++) {
+        /* Make sure it's null */
+        if (result[i])
+            pass = 0;
+    }
+
+    bu_free((void *)result, "test_free");
+
+    return pass;
+}
+
+
+/*
+ * Main Tests
+ */
+/*
+ * Tests the bu_argv_from_string - splitting a string into 'words'
+ */
+int
+test_string(const char *string, int expected_length, char *expected[])
+{
+    char *input;
+    char **result;
+    int result_length;
+    int pass = 1;
+    int i;
+
+    input = bu_strdup(string);
+    result = (char **)bu_calloc((unsigned int)expected_length+1, sizeof(char *), "test_string");
+
+
+    result_length = bu_argv_from_string(result, expected_length, input);
+
+    /* Check the length */
+    if(result_length != expected_length)
+        pass = 0;
+
+    /* Check the data */
+    for (i = 0; i < result_length && i < expected_length; i++) {
+        if (bu_strcmp(expected[i], result[i]) != 0)
+            pass = 0;
+    }
+
+    /* Test other functions */
+    if (!test_duplicate(result_length, result))
+        pass = 0;
+    if (!test_insert(result_length, result))
+        pass = 0;
+    if (!test_free(result_length, result))
+        pass = 0;
+
+    bu_free((void *)input, "test_string");
+    bu_free((void *)result, "test_string");
+
+    return pass;
+}
+
+/*
+ * Tests the bu_argv_from_path - splitting a path (by '/' characters) into
+ * path segments
+ */
+int
+test_path(const char *path, int expected_length, char *expected[])
+{
+    char **result;
+    int result_length = 0;
+    int pass = 1;
+    int i;
+
+    result = bu_argv_from_path(path, &result_length);
+
+    /* Check the length */
+    if(result_length != expected_length)
+        pass = 0;
+
+    /* Check the data if we got any */
+    if (result) {
+        for (i = 0; i < result_length && i < expected_length; i++) {
+            if (bu_strcmp(expected[i], result[i]) != 0)
+                pass = 0;
+        }
+    } else if (result_length != 0) {
+        /* result_length should only be zero if we passed an empty path */
+        pass = 0;
+    }
+
+    /* Test other functions */
+    if (!test_duplicate(result_length, result))
+        pass = 0;
+    if (!test_insert(result_length, result))
+        pass = 0;
+    if (!test_free(result_length, result))
+        pass = 0;
+
+    bu_free_argv(result_length, result);
+    return pass;
+}
+
+int
+main(int argc, char *argv[])
+{
+    char option;
+
+    /* If we don't have any args at all its an error */
+    if (argc == 1) {
+	printf("Need to specify 's' or 'p' option, string test or path test respectively\n");
+        return 1;
+    }
+
+
+    option = *argv[1];
+
+    if(argc == 3)
+        argv[2] = "";
+
+    if (option == 's') {
+        /* Execute a string test */
+        return !test_string(argv[2], argc-3, argv+3);
+    } else if (option == 'p') {
+        /* Execute a path test */
+        return !test_path(argv[2], argc-3, argv+3);
+    } else {
+        printf("Invalid test type.\n");
+        return 1;
+    }
+}
+
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Index: src/libbu/tests/CMakeLists.txt
===================================================================
--- src/libbu/tests/CMakeLists.txt	(revision 54008)
+++ src/libbu/tests/CMakeLists.txt	(working copy)
@@ -293,6 +293,38 @@
 add_test(bu_gettime_test tester_bu_timer)
 
 #
+#  ************ avs.c tests *************
+#
+BRLCAD_ADDEXEC(tester_bu_avs bu_avs.c libbu NO_INSTALL LOCAL)
+add_test(bu_avs_test tester_bu_avs)
+
+#
+#  ************ argv.c tests *************
+#
+#  format is:
+#     bu_argv_test tester_bu_argv s|p "<input to split up>" [<result 1> [<result 2> [...]]]
+#  where s == test a string (split by words)
+#        p == test a path (split by path separators)
+#
+BRLCAD_ADDEXEC(tester_bu_argv bu_argv.c libbu NO_INSTALL LOCAL)
+add_test(bu_argv_test_s1 tester_bu_argv s "")
+add_test(bu_argv_test_s2 tester_bu_argv s "word" word)
+add_test(bu_argv_test_s3 tester_bu_argv s "word " word)
+add_test(bu_argv_test_s4 tester_bu_argv s " word " word)
+add_test(bu_argv_test_s5 tester_bu_argv s "one two" one two)
+add_test(bu_argv_test_s6 tester_bu_argv s "one two " one two)
+add_test(bu_argv_test_s7 tester_bu_argv s "one  two " one two)
+add_test(bu_argv_test_s8 tester_bu_argv s "one two three" one two three)
+
+add_test(bu_argv_test_p1 tester_bu_argv p "")
+add_test(bu_argv_test_p2 tester_bu_argv p "/")
+add_test(bu_argv_test_p3 tester_bu_argv p "/home" home)
+add_test(bu_argv_test_p4 tester_bu_argv p "/home/" home)
+add_test(bu_argv_test_p5 tester_bu_argv p "/home/brlcad" home brlcad)
+add_test(bu_argv_test_p6 tester_bu_argv p "/home/brlcad/" home brlcad)
+
+
+#
 #  ************ vls_vprintf.c tests *************
 #
 BRLCAD_ADDEXEC(tester_bu_vls_vprintf bu_vls_vprintf.c libbu NO_INSTALL LOCAL)
