summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Hall <chris.hall@highwayman.com>2011-07-21 21:40:02 +0100
committerChris Hall <chris.hall@highwayman.com>2011-07-21 21:40:02 +0100
commit228e06bad624a33090da4a09f32f8fed84a7e15c (patch)
tree507a6f0a491d8e5322645cc3ee825711a2dbd20d
parentaee26f69df6bd90c9fe8e9eb8f8ce405ed12ffe5 (diff)
downloadquagga-228e06bad624a33090da4a09f32f8fed84a7e15c.tar.bz2
quagga-228e06bad624a33090da4a09f32f8fed84a7e15c.tar.xz
Disable the "~" VTY Terminal prompt.
Commands sent to the Routing Engine are now sent as priority messages, so should no longer be a need for the "~" prompt which kept the CLI "live" while a command was waiting for the Routing Engine to pay attention. Also: reinstated test-vector.c tests for vector_move_item_here(), which seem somehow to have got lost.
-rw-r--r--lib/vty_cli.c12
-rw-r--r--lib/vty_cli.h2
-rw-r--r--tests/test-vector.c303
3 files changed, 251 insertions, 66 deletions
diff --git a/lib/vty_cli.c b/lib/vty_cli.c
index 83f156ef..a6a276e8 100644
--- a/lib/vty_cli.c
+++ b/lib/vty_cli.c
@@ -179,7 +179,9 @@ uty_cli_new(vio_vf vf)
{
cli->pause_timer = qtimer_init_new(NULL, vty_cli_nexus->pile,
vty_term_pause_timeout, cli) ;
- cli->tilde_enabled = vty_multi_nexus && false ;
+#if 0
+ cli->tilde_enabled = vty_multi_nexus ;
+#endif
} ;
/* Ready to be started -- paused, out_active & more_wait are false.
@@ -259,7 +261,9 @@ uty_cli_close(vty_cli cli, bool final)
/* Discard any pause_timer, and suppress */
cli->pause_timer = qtimer_free(cli->pause_timer) ;
cli->paused = false ;
+#if 0
cli->tilde_enabled = false ;
+#endif
/* If final, free the CLI object. */
if (final)
@@ -813,7 +817,11 @@ uty_cli_dispatch(vty_cli cli)
uty_cmd_signal(vio, CMD_SUCCESS) ;
- cli->blocked = (to_do_now != cmd_do_command) || !cli->tilde_enabled ;
+ cli->blocked = (to_do_now != cmd_do_command)
+#if 0
+ || !cli->tilde_enabled
+#endif
+ ;
}
else
{
diff --git a/lib/vty_cli.h b/lib/vty_cli.h
index e366ecdf..ec00965a 100644
--- a/lib/vty_cli.h
+++ b/lib/vty_cli.h
@@ -95,7 +95,9 @@ struct vty_cli
bool drawn ;
bool tilde_prompt ;
+#if 0
bool tilde_enabled ;
+#endif
int prompt_len ;
int extra_len ;
diff --git a/tests/test-vector.c b/tests/test-vector.c
index 02105e01..c528b9fd 100644
--- a/tests/test-vector.c
+++ b/tests/test-vector.c
@@ -29,7 +29,10 @@ int sort_cmp(void const* const* a, void const* const* b);
void test_vector_sort(void);
void test_vector_bsearch(void);
void test_vector_move_item_here(void);
-void do_test_move_item_here(const int rider);
+void do_test_move_item_here(const int rider, vector_index_t ins,
+ vector_index_t src,
+ char strings[][10],
+ const vector_length_t len) ;
void test_vector_part_reverse(void);
void test_vector_copy_here(void);
void test_vector_move_here(void);
@@ -605,107 +608,279 @@ test_vector_bsearch(void)
void
test_vector_move_item_here(void)
{
- do_test_move_item_here(-1);
- do_test_move_item_here(0);
- do_test_move_item_here(1);
+ const uint n = 20 ;
+ const uint l = n - 1 ;
+ char strings[n][10] ;
+ uint i ;
+
+ for (i = 0 ; i < n ; ++i)
+ sprintf(strings[i], "item=%2u", i) ;
+
+ do_test_move_item_here(-1, 8, 16, strings, n);
+ do_test_move_item_here( 0, 8, 16, strings, n);
+ do_test_move_item_here(+1, 8, 16, strings, n);
+
+ do_test_move_item_here(-1, 16, 8, strings, n);
+ do_test_move_item_here( 0, 16, 8, strings, n);
+ do_test_move_item_here(+1, 16, 8, strings, n);
+
+ do_test_move_item_here(-1, 9, 9, strings, n);
+ do_test_move_item_here( 0, 9, 9, strings, n);
+ do_test_move_item_here(+1, 9, 9, strings, n);
+
+ do_test_move_item_here(-1, 10, 9, strings, n);
+ do_test_move_item_here( 0, 10, 9, strings, n);
+ do_test_move_item_here(+1, 10, 9, strings, n);
+
+ do_test_move_item_here(-1, 9, 10, strings, n);
+ do_test_move_item_here( 0, 9, 10, strings, n);
+ do_test_move_item_here(+1, 9, 10, strings, n);
+
+ do_test_move_item_here(-1, 11, 9, strings, n);
+ do_test_move_item_here( 0, 11, 9, strings, n);
+ do_test_move_item_here(+1, 11, 9, strings, n);
+
+ do_test_move_item_here(-1, 9, 11, strings, n);
+ do_test_move_item_here( 0, 9, 11, strings, n);
+ do_test_move_item_here(+1, 9, 11, strings, n);
+
+ do_test_move_item_here(-1, 0, 10, strings, n);
+ do_test_move_item_here( 0, 0, 10, strings, n);
+ do_test_move_item_here(+1, 0, 10, strings, n);
+
+ do_test_move_item_here(-1, 10, 0, strings, n);
+ do_test_move_item_here( 0, 10, 0, strings, n);
+ do_test_move_item_here(+1, 10, 0, strings, n);
+
+ do_test_move_item_here(-1, 0, l, strings, n);
+ do_test_move_item_here( 0, 0, l, strings, n);
+ do_test_move_item_here(+1, 0, l, strings, n);
+
+ do_test_move_item_here(-1, l, 0, strings, n);
+ do_test_move_item_here( 0, l, 0, strings, n);
+ do_test_move_item_here(+1, l, 0, strings, n);
+
+ do_test_move_item_here(-1, 10, l, strings, n);
+ do_test_move_item_here( 0, 10, l, strings, n);
+ do_test_move_item_here(+1, 10, l, strings, n);
+
+ do_test_move_item_here(-1, l, 10, strings, n);
+ do_test_move_item_here( 0, l, 10, strings, n);
+ do_test_move_item_here(+1, l, 10, strings, n);
+
+ do_test_move_item_here(-1, 0, 0, strings, n);
+ do_test_move_item_here( 0, 0, 0, strings, n);
+ do_test_move_item_here(+1, 0, 0, strings, n);
+
+ do_test_move_item_here(-1, 1, 1, strings, n);
+ do_test_move_item_here( 0, 1, 1, strings, n);
+ do_test_move_item_here(+1, 1, 1, strings, n);
+
+ do_test_move_item_here(-1, 0, 1, strings, n);
+ do_test_move_item_here( 0, 0, 1, strings, n);
+ do_test_move_item_here(+1, 0, 1, strings, n);
+
+ do_test_move_item_here(-1, 1, 0, strings, n);
+ do_test_move_item_here( 0, 1, 0, strings, n);
+ do_test_move_item_here(+1, 1, 0, strings, n);
+
+ do_test_move_item_here(-1, 0, 2, strings, n);
+ do_test_move_item_here( 0, 0, 2, strings, n);
+ do_test_move_item_here(+1, 0, 2, strings, n);
+
+ do_test_move_item_here(-1, 2, 0, strings, n);
+ do_test_move_item_here( 0, 2, 0, strings, n);
+ do_test_move_item_here(+1, 2, 0, strings, n);
+
+ do_test_move_item_here(-1, l, l, strings, n);
+ do_test_move_item_here( 0, l, l, strings, n);
+ do_test_move_item_here(+1, l, l, strings, n);
+
+ do_test_move_item_here(-1,l-1, l, strings, n);
+ do_test_move_item_here( 0,l-1, l, strings, n);
+ do_test_move_item_here(+1,l-1, l, strings, n);
+
+ do_test_move_item_here(-1, l,l-1, strings, n);
+ do_test_move_item_here( 0, l,l-1, strings, n);
+ do_test_move_item_here(+1, l,l-1, strings, n);
}
void
-do_test_move_item_here(const int rider)
+do_test_move_item_here(const int rider, vector_index_t ins,
+ vector_index_t src,
+ char strings[][10],
+ const vector_length_t len)
{
vector v = NULL;
- const vector_length_t len = 100;
- const vector_index_t ins = 50;
- const vector_index_t src = 70;
- vector_index_t i;
- char buf[10];
- vector_index_t check_dest = 0;
- vector_index_t check_src = 0;
- vector_index_t check_end = 0;
- int check_shift = 0;
- p_vector_item dest_item = NULL;
+ vector_index_t i, e, check_end ;
+ vector_index_t hi, lo ;
+ char* expect[len] ;
+ p_vector_item dest_item = NULL;
switch(rider)
{
case -1:
- printf("test_vector_move_here before\n");
- check_dest = ins;
- check_src = src;
- check_end = len;
- check_shift = 1;
+ printf("test_vector_move_here before dst=%2d, src=%2d\n", src, ins);
break;
+
case 0:
- printf("test_vector_move_here at\n");
- check_dest = ins;
- check_src = src - 1;
- check_end = len - 1;
- check_shift = 0;
+ printf("test_vector_move_here at dst=%2d, src=%2d\n", src, ins);
break;
+
case 1:
- printf("test_vector_move_here after\n");
- check_dest = ins + 1;
- check_src = src;
- check_end = len;
- check_shift = 1;
+ printf("test_vector_move_here after dst=%2d, src=%2d\n", src, ins);
break;
- }
+ } ;
+
+ /* Build the test vector and perform action */
v = vector_init_new(v, 0);
for (i = 0; i < len; ++i)
- {
- sprintf(buf, "%u", i);
- vector_set_item(v, i, strdup(buf));
- }
+ vector_set_item(v, i, strdup(strings[i]));
dest_item = vector_get_item(v, ins); /* item to free if rider == 0 */
vector_move_item_here(v, ins, rider, src);
- assert_true(vector_end(v) == check_end, "vector_end(v) != check_end");
- /* check contents are correct */
+ /* Build the expected result. */
- /* from start to insertion point */
- for (i = 0; i < check_dest - 1; ++i)
+ if (ins <= src)
{
- sprintf(buf, "%u", i);
- assert_true(strcmp(vector_get_item(v, i), buf) == 0,
- "vector_get_item(v, i) != buf");
+ lo = ins ;
+ hi = src ;
}
+ else
+ {
+ lo = src ;
+ hi = ins ;
+ } ;
- /* at insertion point */
- sprintf(buf, "%u", src);
- assert_true(strcmp(vector_get_item(v, check_dest), buf) == 0,
- "vector_get_item(v, check_dest) != buf");
+ check_end = (rider != 0) ? len : len - 1 ;
+ i = 0 ;
+ e = 0 ;
- /* from insertion point to src */
- for (i = check_dest + 1; i <= check_src; ++i)
+ while (i < lo)
+ expect[i++] = strings[e++] ;
+
+ if (lo == hi)
{
- sprintf(buf, "%u", i - check_shift);
- assert_true(strcmp(vector_get_item(v, i), buf) == 0, "vector_get_item(v, i) != buf");
+ /* Special case -- do nothing if rider != 0
+ * drop entry if rider == 0
+ */
+ if (rider == 0)
+ ++e ;
}
-
- /* from src to end */
- for (i = check_src + 1; i < check_end; ++i)
+ else if (lo == (hi - 1))
{
- sprintf(buf, "%u", i - (check_shift - 1));
- assert_true(strcmp(vector_get_item(v, i), buf) == 0, "vector_get_item(v, i) != buf");
+ /* Special case -- ins and src next to each other !
+ *
+ * If rider != 0 -- insert ins and src in the required order
+ * If rider == 0 -- insert just src
+ */
+ if (rider < 0)
+ {
+ expect[i++] = strings[src] ;
+ expect[i++] = strings[ins] ;
+ }
+ else if (rider == 0)
+ {
+ expect[i++] = strings[src] ;
+ }
+ else
+ {
+ expect[i++] = strings[ins] ;
+ expect[i++] = strings[src] ;
+ } ;
+ e += 2 ;
}
+ else
+ {
+ /* Now we know that ins and src are separated by at least 1 entry.
+ */
+ uint be ;
+
+ be = hi - 1 ;
+
+ if (ins < src)
+ {
+ /* At insertion point, so insert ins and src in the required order
+ * or insert juist the src.
+ */
+ if (rider < 0)
+ {
+ expect[i++] = strings[src] ;
+ expect[i++] = strings[ins] ;
+ ++be ;
+ }
+ else if (rider == 0)
+ {
+ expect[i++] = strings[src] ;
+ }
+ else
+ {
+ expect[i++] = strings[ins] ;
+ expect[i++] = strings[src] ;
+ ++be ;
+ } ;
+
+ ++be ;
+ } ;
+
+ e += 1 ;
+
+ while (i < be)
+ expect[i++] = strings[e++] ;
+
+ if (ins > src)
+ {
+ /* At insertion point, so insert ins and src in the required order
+ * or insert juist the src.
+ */
+ if (rider < 0)
+ {
+ expect[i++] = strings[src] ;
+ expect[i++] = strings[ins] ;
+ }
+ else if (rider == 0)
+ {
+ expect[i++] = strings[src] ;
+ }
+ else
+ {
+ expect[i++] = strings[ins] ;
+ expect[i++] = strings[src] ;
+ } ;
+ } ;
+
+ e = hi + 1 ;
+ } ;
+
+ while (i < check_end)
+ expect[i++] = strings[e++] ;
+
+ /* check contents are correct */
+ assert_true(vector_end(v) == check_end, "vector_end(v) != check_end");
- /* free contents */
- for (i = 0; i < vector_end(v); ++i)
+ for (i = 0 ; i < check_end ; ++i)
{
- free(vector_slot(v, i));
- }
+ if (strcmp(vector_get_item(v, i), expect[i]) != 0)
+ {
+ assert_true(0, "vector_get_item(v, i) != expected") ;
+ break ;
+ } ;
+ } ;
+
+ /* free contents */
+ for (i = 0; i < vector_end(v); ++i)
+ free(vector_slot(v, i));
if (rider == 0)
- {
- free(dest_item);
- }
+ free(dest_item);
- vector_free(v);
-}
+ vector_free(v);
+} ;
void
test_vector_part_reverse(void)