2
** Copyright (C) 1991, 1997 Free Software Foundation, Inc.
4
** This file is part of TACK.
6
** TACK is free software; you can redistribute it and/or modify
7
** it under the terms of the GNU General Public License as published by
8
** the Free Software Foundation; either version 2, or (at your option)
11
** TACK is distributed in the hope that it will be useful,
12
** but WITHOUT ANY WARRANTY; without even the implied warranty of
13
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
** GNU General Public License for more details.
16
** You should have received a copy of the GNU General Public License
17
** along with TACK; see the file COPYING. If not, write to
18
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
** Boston, MA 02110-1301, USA
24
MODULE_ID("$Id: modes.c,v 1.2 2005/09/17 19:49:16 tom Exp $")
27
* Tests boolean flags and terminal modes.
29
static void subtest_os(struct test_list *, int *, int *);
30
static void subtest_rmam(struct test_list *, int *, int *);
31
static void subtest_smam(struct test_list *, int *, int *);
32
static void subtest_am(struct test_list *, int *, int *);
33
static void subtest_ul(struct test_list *, int *, int *);
34
static void subtest_uc(struct test_list *, int *, int *);
35
static void subtest_bw(struct test_list *, int *, int *);
36
static void subtest_xenl(struct test_list *, int *, int *);
37
static void subtest_eo(struct test_list *, int *, int *);
38
static void subtest_xmc(struct test_list *, int *, int *);
39
static void subtest_xhp(struct test_list *, int *, int *);
40
static void subtest_mir(struct test_list *, int *, int *);
41
static void subtest_msgr(struct test_list *, int *, int *);
42
static void subtest_tbc(struct test_list *, int *, int *);
43
static void subtest_xt(struct test_list *, int *, int *);
44
static void subtest_hts(struct test_list *, int *, int *);
45
static void subtest_cbt(struct test_list *, int *, int *);
46
static void subtest_in(struct test_list *, int *, int *);
47
static void subtest_dadb(struct test_list *, int *, int *);
49
struct test_list mode_test_list[] = {
50
{0, 0, 0, 0, "e) edit terminfo", 0, &edit_menu},
51
{MENU_NEXT, 3, "os", 0, 0, subtest_os, 0},
52
{MENU_NEXT, 1, "rmam", 0, 0, subtest_rmam, 0},
53
{MENU_NEXT, 1, "smam", 0, 0, subtest_smam, 0},
54
{MENU_NEXT, 1, "am", 0, 0, subtest_am, 0},
55
{MENU_NEXT, 3, "ul", 0, 0, subtest_ul, 0},
56
{MENU_NEXT, 3, "uc", 0, 0, subtest_uc, 0},
57
{MENU_NEXT, 3, "bw", 0, 0, subtest_bw, 0},
58
{MENU_NEXT, 4, "xenl", 0, 0, subtest_xenl, 0},
59
{MENU_NEXT, 3, "eo", 0, 0, subtest_eo, 0},
60
{MENU_NEXT, 3, "xmc", 0, 0, subtest_xmc, 0},
61
{MENU_NEXT, 3, "xhp", 0, 0, subtest_xhp, 0},
62
{MENU_NEXT, 6, "mir", 0, 0, subtest_mir, 0},
63
{MENU_NEXT, 6, "msgr", 0, 0, subtest_msgr, 0},
64
{MENU_NEXT | MENU_CLEAR, 0, "tbc", "it", 0, subtest_tbc, 0},
65
{MENU_NEXT | MENU_CLEAR, 0, "hts", "it", 0, subtest_hts, 0},
66
{MENU_NEXT, 4, "xt", "it", 0, subtest_xt, 0},
67
{MENU_NEXT, 1, "cbt", "it", 0, subtest_cbt, 0},
68
{MENU_NEXT, 6, "in", 0, 0, subtest_in, 0},
69
{MENU_NEXT, 1, "da) (db", 0, 0, subtest_dadb, 0},
70
{MENU_LAST, 0, 0, 0, 0, 0, 0}
74
** subtest_os(test_list, status, ch)
76
** test over strike mode (os)
84
ptext("(os) should be true, not false.");
86
ptextln("(os) should be false.");
87
sprintf(temp, "(os) over-strike is %s in the data base. ",
88
over_strike ? "true" : "false");
90
generic_done_message(t, state, ch);
94
** subtest_rmam(test_list, status, ch)
96
** test exit automatic margins mode (rmam)
107
ptext("(rmam) not present. ");
110
ptext("(rmam) not tested, no way to home cursor. ");
115
tc_putp(exit_am_mode);
116
ptext("\n(rmam) will reset (am)");
118
for (j = 0; j < columns; j++)
120
ptext("(rmam) will not reset (am)");
126
tc_putp(exit_am_mode);
127
ptext("\n(rmam) will reset (am)");
129
for (j = 0; j < columns; j++)
131
ptext("(rmam) will not reset (am) ");
137
ptext("Exit-automatic-margins ");
138
generic_done_message(t, state, ch);
142
** subtest_smam(test_list, status, ch)
144
** test enter automatic margins mode (smam)
154
if (!enter_am_mode) {
155
ptext("(smam) not present. ");
158
ptext("(smam) not tested, no way to home cursor. ");
163
tc_putp(enter_am_mode);
164
ptext("\n(smam) will ");
166
ptext("not set (am)");
168
for (j = -i; j < columns; j++)
175
tc_putp(enter_am_mode);
176
ptext("\n(smam) will not set (am)");
178
for (j = 0; j < columns; j++)
180
ptext("(smam) will set (am) ");
185
ptext("Enter-automatic-margins ");
186
generic_done_message(t, state, ch);
190
** subtest_am(test_list, status, ch)
192
** test automatic margins (am)
203
ptextln("(am) not tested, no way to home cursor. ");
208
ptext("\n(am) should ");
212
for (j = -i; j < columns; j++)
217
sprintf(temp, "(am) is %s in the data base",
218
auto_right_margin ? "true" : "false");
223
ptext("\n(am) should not be set");
225
for (j = 0; j < columns; j++)
227
ptext("(am) should be set ");
230
sprintf(temp, "(am) is %s in the data base",
231
auto_right_margin ? "true" : "false");
234
ptext("Automatic-right-margin ");
235
generic_done_message(t, state, ch);
238
/* Note: uprint() sends underscore back-space character, and
239
ucprint() sends character back-space underscore. */
244
** underline string for (ul) test
247
uprint(const char *s)
260
** underline string for (uc) test
263
ucprint(const char *s)
269
tc_putp(underline_char);
275
** subtest_ul(test_list, status, ch)
277
** test transparent underline (ul)
286
/* (ul) is used only if (os) is reset */
288
sprintf(temp, "This text should %sbe underlined.",
289
transparent_underline ? "" : "not ");
292
ptextln("If the above line is not underlined the (ul) should be false.");
293
sprintf(temp, "(ul) Transparent-underline is %s in the data base",
294
transparent_underline ? "true" : "false");
296
generic_done_message(t, state, ch);
301
** subtest_uc(test_list, status, ch)
303
** test underline character (uc)
312
if (underline_char) {
313
ucprint("This text should be underlined.");
315
ptextln("If the above text is not underlined the (uc) has failed.");
316
ptext("Underline-character ");
318
ptext("(uc) underline-character is not defined. ");
320
generic_done_message(t, state, ch);
325
** subtest_bw(test_list, status, ch)
327
** test auto left margin (bw)
339
ptext("\n(bw) should ");
341
ptextln("not be set.");
342
for (j = i; j < columns; j++)
346
sprintf(temp, "(bw) Auto-left-margin is %s in the data base",
347
auto_left_margin ? "true" : "false");
351
ptextln("(bw) should not be set.");
352
for (i = 12; i < columns; i++)
354
if (delete_character) {
355
for (i = 0; i < 4; i++)
356
tc_putp(delete_character);
361
sprintf(temp, "(bw) Auto-left-margin is %s in the data base",
362
auto_left_margin ? "true" : "false");
365
generic_done_message(t, state, ch);
369
** subtest_tbc(test_list, status, ch)
371
** test clear tabs (tbc)
379
int tabat; /* the tab spacing we end up with */
382
if (clear_all_tabs && !set_tab) {
383
ptext("(tbc) Clear-all-tabs is defined but (hts) set-tab is not. ");
384
ptext("Once the tabs are cleared there is no way to set them. ");
386
if (clear_all_tabs) {
387
tabat = set_tab ? 8 : init_tabs;
388
tc_putp(clear_all_tabs);
389
ptext("Clear tabs (tbc)");
396
for (i = 0; i < columns; i++) {
404
ptext("\n\n\nIf the above two lines have T's in the same column then (tbc) has failed. ");
406
ptext("(tbc) Clear-all-tabs is not defined. ");
408
generic_done_message(t, state, ch);
412
** subtest_hts(test_list, status, ch)
414
** (ht) and set tabs with (hts)
422
int tabat; /* the tab spacing we end up with */
427
ptext("Tabs set with (hts)");
429
for (i = 1; i < columns; i++) {
437
sprintf(temp, "(hts) Set-tabs not defined. (it) Initial-tabs at %d", init_tabs);
445
for (i = tabat; i < columns; i += tabat) {
451
for (i = 1; i < columns; i++) {
456
for (i = tabat; i < columns; i += tabat) {
463
for (i = 2; i < columns; i++) {
464
if (i % tabat == 1) {
473
ptextln("If the last two lines are not the same then (hts) has failed.");
476
ptextln("If the last two lines are not the same then (it) is wrong.");
478
ptextln("If the last two lines are the same then maybe you do have tabs and (it) should be changed.");
480
generic_done_message(t, state, ch);
484
** subtest_xt(test_list, status, ch)
494
int tabat; /* the tab spacing we end up with */
497
tabat = set_tab ? 8 : init_tabs;
498
if (!over_strike && (tabat > 0)) {
499
ptext("(xt) should not ");
501
ptext("(xt) should");
505
cc = ((cc / tabat) + 1) * tabat;
508
sprintf(temp, "(xt) Destructive-tab is %s in the data base.",
509
dest_tabs_magic_smso ? "true" : "false");
511
generic_done_message(t, state, ch);
516
** subtest_cbt(test_list, status, ch)
530
ptext("Back-tab (cbt)");
533
for (i = 1; i < columns; i++) {
536
for (i = 0; i < columns; i += 8) {
543
for (i = 1; i < columns; i++) {
552
ptextln("The preceding two lines should be the same.");
554
ptextln("(cbt) Back-tab not present");
556
generic_done_message(t, state, ch);
560
** subtest_xenl(test_list, status, ch)
562
** (xenl) eat newline glitch
573
/* test (xenl) on overstrike terminals */
574
if (!can_go_home || !can_clear_screen) {
575
ptextln("(xenl) Newline-glitch not tested, can't home cursor and clear.");
576
generic_done_message(t, state, ch);
581
this test must be done in raw mode. Otherwise UNIX will
582
translate CR to CRLF.
584
if (stty_query(TTY_OUT_TRANS))
585
tty_raw(1, char_mask);
586
ptext("\nreset (xenl). Does ");
588
put_str("not ignore CR, does ");
590
put_str("not ignore LF");
592
for (j = 0; j < columns; j++)
595
for (j = 0; j < i; j++)
599
for (j = 0; j < columns; j++)
602
for (j = 0; j < k; j++)
608
sprintf(temp, "(xenl) Newline-glitch is %s in the data base",
609
eat_newline_glitch ? "true" : "false");
612
/* test (xenl) when (os) is reset */
614
ptextln("(xenl) Newline-glitch not tested, can't home cursor");
615
generic_done_message(t, state, ch);
621
this test must be done in raw mode. Otherwise
622
UNIX will translate CR to CRLF.
624
if (stty_query(TTY_OUT_TRANS))
625
tty_raw(1, char_mask);
626
for (j = 0; j < columns; j++)
629
ptext("(xenl) should be set. Does not ignore CR");
632
for (j = 0; j < columns; j++)
634
put_lf(); /* test (cud1) */
635
ptext("(xenl) should be set. Ignores (cud1)");
638
if (scroll_forward && cursor_down &&
639
strcmp(scroll_forward, cursor_down)) {
640
for (j = 0; j < columns; j++)
642
put_ind(); /* test (ind) */
643
ptext("(xenl) should be set. Ignores (ind)");
648
ptextln("If you don't see text above telling you to set it, (xenl) should be false");
649
sprintf(temp, "(xenl) Newline-glitch is %s in the data base",
650
eat_newline_glitch ? "true" : "false");
653
generic_done_message(t, state, ch);
657
** subtest_eo(test_list, status, ch)
659
** (eo) erase overstrike
667
if (transparent_underline || over_strike || underline_char) {
668
ptext("(eo) should ");
669
if (underline_char) {
675
ptextln("(eo) should be set");
676
sprintf(temp, "\n(eo) Erase-overstrike is %s in the data base",
677
erase_overstrike ? "true" : "false");
679
generic_done_message(t, state, ch);
684
** subtest_xmc(test_list, status, ch)
686
** (xmc) magic cookie glitch
696
if (enter_standout_mode) {
697
sprintf(temp, "\n(xmc) Magic-cookie-glitch is %d in the data base", magic_cookie_glitch);
699
j = magic_cookie_glitch * 8;
700
for (i = 0; i < j; i++) {
703
ptextln(" These two lines should line up.");
707
for (i = 0; i < 4; i++) {
708
put_mode(enter_standout_mode);
710
put_mode(exit_standout_mode);
713
ptextln("These two lines should line up.");
714
ptext("If they don't line up then (xmc) magic-cookie-glitch should be greater than zero. ");
715
generic_done_message(t, state, ch);
720
** subtest_xhp(test_list, status, ch)
722
** (xhp) erase does not clear standout mode
730
if (enter_standout_mode) {
732
put_mode(enter_standout_mode);
733
put_str("Stand out");
734
put_mode(exit_standout_mode);
736
ptextln("If any part of this line is standout then (xhp) should be set.");
737
sprintf(temp, "(xhp) Erase-standout-glitch is %s in the data base",
738
ceol_standout_glitch ? "true" : "false");
740
generic_done_message(t, state, ch);
745
** subtest_mir(test_list, status, ch)
747
** (mir) move in insert mode
758
if (enter_insert_mode && exit_insert_mode && cursor_address) {
761
put_str("\nXXX\nXXX\nXXX\nXXX");
762
tc_putp(enter_insert_mode);
763
s = tparm(cursor_address, i + 1, 0);
764
tputs(s, lines, tc_putch);
766
s = tparm(cursor_address, i + 2, 1);
767
tputs(s, lines, tc_putch);
769
s = tparm(cursor_address, i + 3, 2);
770
tputs(s, lines, tc_putch);
772
s = tparm(cursor_address, i + 4, 3);
773
tputs(s, lines, tc_putch);
775
tc_putp(exit_insert_mode);
777
ptextln("If you see a 4 by 4 block of X's then (mir) should be true.");
778
sprintf(temp, "(mir) Move-in-insert-mode is %s in the data base",
779
move_insert_mode ? "true" : "false");
782
ptext("(mir) Move-in-insert-mode not tested, ");
783
if (!enter_insert_mode) {
786
if (!exit_insert_mode) {
789
if (!cursor_address) {
792
ptext("not present. ");
794
generic_done_message(t, state, ch);
798
** subtest_msgr(test_list, status, ch)
800
** (msgr) move in sgr mode
810
if (cursor_address &&
811
((enter_standout_mode && exit_standout_mode) ||
812
(enter_alt_charset_mode && exit_alt_charset_mode))) {
815
tputs(tparm(cursor_address, i, 0), lines, tc_putch);
816
put_mode(enter_alt_charset_mode);
819
some versions of the wy-120 can not clear lines or
820
screen when in alt charset mode. If (el) and (ed)
821
are defined then I can test them. If they are not
822
defined then they can not break (msgr)
826
put_mode(exit_alt_charset_mode);
827
put_mode(enter_standout_mode);
829
tputs(tparm(cursor_address, i + 2, 1), lines, tc_putch);
831
tputs(tparm(cursor_address, i + 3, 2), lines, tc_putch);
833
tputs(tparm(cursor_address, i + 4, 3), lines, tc_putch);
835
put_mode(exit_standout_mode);
837
tc_putp(clr_eos); /* OK if missing */
839
ptextln("If you see a diagonal line of standout X's then (msgr) should be true. If any of the blanks are standout then (msgr) should be false.");
840
sprintf(temp, "(msgr) Move-in-SGR-mode is %s in the data base",
841
move_standout_mode ? "true" : "false");
844
ptextln("(smso) (rmso) (smacs) (rmacs) missing; (msgr) Move-in-SGR-mode not tested.");
846
generic_done_message(t, state, ch);
850
** subtest_in(test_list, status, ch)
852
** (in) insert null glitch
860
if (enter_insert_mode && exit_insert_mode) {
861
ptextln("\nTesting (in) with (smir) and (rmir)");
862
putln("\tIf these two lines line up ...");
863
put_str("\tIf these two lines line up ...");
865
tc_putp(enter_insert_mode);
867
tc_putp(exit_insert_mode);
868
ptext("\nthen (in) should be set. ");
870
"(in) Insert-null-glitch is %s in the data base.",
871
insert_null_glitch ? "true" : "false");
873
generic_done_message(t, state, ch);
878
** subtest_dadb(test_list, status, ch)
880
** (da) (db) data above, (db) data below
888
if (can_clear_screen && scroll_reverse && scroll_forward) {
891
ptext("(da) Data-above should be set\r");
894
ptext("(db) Data-below should be set\r");
895
tc_putp(scroll_forward);
897
tc_putp(scroll_reverse);
898
tc_putp(scroll_reverse);
900
tc_putp(scroll_forward);
902
ptextln("\n\n\n\n\nIf the top line is blank then (da) should be false.");
903
ptextln("If the bottom line is blank then (db) should be false.");
904
sprintf(temp, "\n(da) Data-above is %s, and (db) Data-below is %s, in the data base.",
905
memory_above ? "true" : "false",
906
memory_below ? "true" : "false");
910
ptextln("(da) Data-above, (db) Data-below not tested, scrolls or (clear) is missing.");
912
generic_done_message(t, state, ch);