home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / EMSLB221.ZIP / EMSTEST2.C < prev    next >
C/C++ Source or Header  |  1991-10-11  |  42KB  |  1,062 lines

  1. /***************************************************************************
  2. *   emstest2.c                                                             *
  3. *   MODULE:  EMSLIB                                                        *
  4. *   OS:      DOS                                                           *
  5. *   VERSION: 1.1                                                           *
  6. *   DATE:    10/10/91                                                      *
  7. *                                                                          *
  8. *   Copyright (c) 1991 James W. Birdsall. All Rights Reserved.             *
  9. *                                                                          *
  10. *   Requires emslib.h and emstest.h to compile.                            *
  11. *   Compiles under Borland C++ 2.0 or MSC 6.0A.                            *
  12. *                                                                          *
  13. *   Regression test and example for EMSLIB. See EMSTEST.C for more detail. *
  14. *                                                                          *
  15. ***************************************************************************/
  16.  
  17. /*
  18. ** system includes <>
  19. */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <dos.h>
  24. #include <string.h>
  25.  
  26.  
  27. /*
  28. ** custom includes ""
  29. */
  30.  
  31. #include "emslib.h"
  32. #include "emstest.h"
  33.  
  34.  
  35. /*
  36. ** local #defines
  37. */
  38.  
  39. #define UCF                      unsigned char far
  40.  
  41. /*
  42. ** Checks to see if a region of memory is still incrementing word values,
  43. ** handles cleanup and exit if not.
  44. */
  45. #define WORDCHECK(buf, len, msg)                                \
  46.     if (farincwordcheck((UCF *) (buf), (len)) != 0) {           \
  47.         printf("Copy corrupted %s.\n", (msg)); EMMfree(handle); \
  48.         free(testbuf); exit(3); }
  49.  
  50. /*
  51. ** Check source and destination buffers, respectively.
  52. */
  53. #define SRCWORDCHECK(buf, len)    WORDCHECK(buf, len, "source buffer")
  54. #define CPYWORDCHECK(buf, len)    WORDCHECK(buf, len, "copied bytes")
  55.  
  56. /*
  57. ** Checks to see if a region of memory is still filled with a given value,
  58. ** handles cleanup and exit if not.
  59. */
  60. #define MEMCHECK(buf, len, val)                          \
  61.     if (farmemcheck((UCF *) (buf), (len), (val)) != 0) { \
  62.         printf("Copy corrupted destination.\n");         \
  63.         EMMfree(handle); free(testbuf); exit(3); }
  64.  
  65. /*
  66. ** Checks buffer for nonzero values.
  67. */
  68. #define ZEROCHECK(buf, len)       MEMCHECK(buf, len, '\0')
  69.  
  70. /*
  71. ** Compares two regions of memory, handles cleanup and exit if not the same.
  72. */
  73. #define MEMCMP(buf1, buf2, len)                                          \
  74.     if (FMEMCMP((void far *) (buf1), (void far *) (buf2), (len)) != 0) { \
  75.         printf("Copy corrupted copied bytes.\n"); EMMfree(handle);       \
  76.         free(testbuf); exit(3); }
  77.  
  78.  
  79. /*
  80. ** misc: copyright strings, version macros, etc.
  81. */
  82.  
  83. /*
  84. ** typedefs
  85. */
  86.  
  87. /*
  88. ** global variables
  89. */
  90.  
  91. /* see EMSTEST.C for info */
  92. extern int testno;
  93. extern unsigned char far *frameptr[];
  94. extern char *gblmsg;
  95.  
  96.  
  97. /*
  98. ** static globals
  99. */
  100.  
  101. /*
  102. ** function prototypes
  103. */
  104.  
  105. static void do_nshortcopy_tests(void);
  106. static void do_ishortcopy_tests(void);
  107.  
  108.  
  109. /*
  110. ** functions
  111. */
  112.  
  113.  
  114. /***************************************************************************
  115. *   FUNCTION: DO_SHORTCOPY_TESTS                                           *
  116. *                                                                          *
  117. *   DESCRIPTION:                                                           *
  118. *                                                                          *
  119. *       Central dispatching function for short copy tests.                 *
  120. *                                                                          *
  121. *   ENTRY:                                                                 *
  122. *                                                                          *
  123. *       Void.                                                              *
  124. *                                                                          *
  125. *   EXIT:                                                                  *
  126. *                                                                          *
  127. *       Void.                                                              *
  128. *                                                                          *
  129. *   CONSTRAINTS/SIDE EFFECTS:                                              *
  130. *                                                                          *
  131. ***************************************************************************/
  132. void do_shortcopy_tests(void)
  133. {
  134.     do_nshortcopy_tests();
  135.     do_ishortcopy_tests();
  136.     return;
  137. } /* end of do_shortcopy_tests() */
  138.  
  139.  
  140. /***************************************************************************
  141. *   FUNCTION: DO_NSHORTCOPY_TESTS  (STATIC)                                *
  142. *                                                                          *
  143. *   DESCRIPTION:                                                           *
  144. *                                                                          *
  145. *       Tests EMSLIB functions EMMcopyto() and EMMcopyfrom() with copies   *
  146. *       shorter than one EMS page ( <= 16384 bytes ).                      *
  147. *                                                                          *
  148. *   ENTRY:                                                                 *
  149. *                                                                          *
  150. *       Void.                                                              *
  151. *                                                                          *
  152. *   EXIT:                                                                  *
  153. *                                                                          *
  154. *       Void.                                                              *
  155. *                                                                          *
  156. *   CONSTRAINTS/SIDE EFFECTS:                                              *
  157. *                                                                          *
  158. ***************************************************************************/
  159. static void do_nshortcopy_tests(void)
  160. {
  161.     unsigned char *testbuf;
  162.     int handle;
  163.     int status;
  164.     unsigned long ticks, totticks;
  165.     int loop;
  166.  
  167.     /* allocate memory to test against */
  168.     testbuf = (unsigned char *) malloc(16384);
  169.     if (testbuf == (unsigned char *) NULL)
  170.     {
  171.         printf("Cannot allocate test memory. Aborting.\n");
  172.         exit(1);
  173.     }
  174.  
  175.     /* now allocate a page of EMS to test with */
  176.     handle = test_EMMallocpages(1);
  177.  
  178.     /* fill test buffer with incrementing word pattern */
  179.     farincwordfill((UCF *) testbuf, 16384);
  180.  
  181.     /* fill EMS page with a different pattern */
  182.     test_EMMmappage(0, handle, 0);
  183.     FMEMSET(frameptr[0], 0, 16384);
  184.  
  185.     /* try a bad copy first */
  186.     TESTHEADER();
  187.     printf("Calling EMMcopyto() with bad offset.\n");
  188.     printf("Should fail.\n");
  189.     status = EMMcopyto(5L, (UCF *) testbuf, handle, 20000L);
  190.     nofailcheck("EMMcopyto()", status, testbuf, handle, 0);
  191.     weirdretchk("EMMcopyto()", status, testbuf, handle, 0);
  192.     weirdcodechk("EMMcopyto()", EMM_BADOFFSET, testbuf, handle, 0);
  193.     SRCWORDCHECK(testbuf, 16384);
  194.     test_EMMmappage(0, handle, 0);
  195.     ZEROCHECK(frameptr[0], 16384);
  196.     printf("EMMcopyto() failed OK.\n");
  197.     TESTTAILER();
  198.  
  199.     /* and another */
  200.     TESTHEADER();
  201.     printf("Calling EMMcopyto() with block that runs off end of EMS.\n");
  202.     printf("Should fail.\n");
  203.     status = EMMcopyto(500L, (UCF *) testbuf, handle, 16000L);
  204.     nofailcheck("EMMcopyto()", status, testbuf, handle, 0);
  205.     weirdretchk("EMMcopyto()", status, testbuf, handle, 0);
  206.     weirdcodechk("EMMcopyto()", EMM_BADOFFSET, testbuf, handle, 0);
  207.     SRCWORDCHECK(testbuf, 16384);
  208.     test_EMMmappage(0, handle, 0);
  209.     ZEROCHECK(frameptr[0], 16384);
  210.     printf("EMMcopyto() failed OK.\n");
  211.     TESTTAILER();
  212.  
  213.     /* test zero-length copy */
  214.     TESTHEADER();
  215.     printf("Calling EMMcopyto() with zero-length source block.\n");
  216.     printf("Should succeed.\n");
  217.     status = EMMcopyto(0L, (UCF *) testbuf, handle, 0L);
  218.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  219.     SRCWORDCHECK(testbuf, 16384);
  220.     test_EMMmappage(0, handle, 0);
  221.     ZEROCHECK(frameptr[0], 16384);
  222.     printf("EMMcopyto() succeeded.\n");
  223.     TESTTAILER();
  224.  
  225.     /* test copy of even number of bytes to 0 offset */
  226.     TESTHEADER();
  227.     printf("Calling EMMcopyto() to copy 50 bytes to offset 0.\n");
  228.     status = EMMcopyto(50L, (UCF *) testbuf, handle, 0L);
  229.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  230.     SRCWORDCHECK(testbuf, 16384);
  231.     test_EMMmappage(0, handle, 0);
  232.     CPYWORDCHECK(frameptr[0], 50);
  233.     ZEROCHECK((frameptr[0] + 50), 16384 - 50);
  234.     printf("EMMcopyto() succeeded.\n");
  235.     TESTTAILER();
  236.  
  237.     /* restore EMS pattern */
  238.     test_EMMmappage(0, handle, 0);
  239.     FMEMSET(frameptr[0], 0, 16384);
  240.  
  241.     /* test copy of even number of bytes to even offset */
  242.     TESTHEADER();
  243.     printf("Calling EMMcopyto() to copy 50 bytes to even offset.\n");
  244.     status = EMMcopyto(50L, (UCF *) testbuf, handle, 498L);
  245.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  246.     SRCWORDCHECK(testbuf, 16384);
  247.     test_EMMmappage(0, handle, 0);
  248.     CPYWORDCHECK((frameptr[0] + 498), 50);
  249.     ZEROCHECK(frameptr[0], 498);
  250.     ZEROCHECK((frameptr[0] + 498 + 50), ((16384 - 498) - 50));
  251.     printf("EMMcopyto() succeeded.\n");
  252.     TESTTAILER();
  253.  
  254.     /* restore EMS pattern */
  255.     test_EMMmappage(0, handle, 0);
  256.     FMEMSET(frameptr[0], 0, 16384);
  257.  
  258.     /* test copy of even number of bytes to odd offset */
  259.     TESTHEADER();
  260.     printf("Calling EMMcopyto() to copy 50 bytes to odd offset.\n");
  261.     status = EMMcopyto(50L, (UCF *) testbuf, handle, 777L);
  262.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  263.     SRCWORDCHECK(testbuf, 16384);
  264.     test_EMMmappage(0, handle, 0);
  265.     CPYWORDCHECK((frameptr[0] + 777), 50);
  266.     ZEROCHECK(frameptr[0], 777);
  267.     ZEROCHECK((frameptr[0] + 777 + 50), ((16384 - 777) - 50));
  268.     printf("EMMcopyto() succeeded.\n");
  269.     TESTTAILER();
  270.  
  271.     /* restore EMS pattern */
  272.     test_EMMmappage(0, handle, 0);
  273.     FMEMSET(frameptr[0], 0, 16384);
  274.  
  275.     /* test copy of even number of bytes to offset just before end */
  276.     TESTHEADER();
  277.     printf(
  278.          "Calling EMMcopyto() to copy 50 bytes to just before end of page.\n");
  279.     status = EMMcopyto(50L, (UCF *) testbuf, handle, (16384L - 50L));
  280.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  281.     SRCWORDCHECK(testbuf, 16384);
  282.     test_EMMmappage(0, handle, 0);
  283.     CPYWORDCHECK((frameptr[0] + (16384 - 50)), 50);
  284.     ZEROCHECK(frameptr[0], (16384 - 50));
  285.     printf("EMMcopyto() succeeded.\n");
  286.     TESTTAILER();
  287.  
  288.     /* restore EMS pattern */
  289.     test_EMMmappage(0, handle, 0);
  290.     FMEMSET(frameptr[0], 0, 16384);
  291.  
  292.     /* test copy of odd number of bytes to 0 offset */
  293.     TESTHEADER();
  294.     printf("Calling EMMcopyto() to copy 77 bytes to offset 0.\n");
  295.     status = EMMcopyto(77L, (UCF *) testbuf, handle, 0L);
  296.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  297.     SRCWORDCHECK(testbuf, 16384);
  298.     test_EMMmappage(0, handle, 0);
  299.     MEMCMP(frameptr[0], testbuf, 77);
  300.     ZEROCHECK((frameptr[0] + 77), 16384 - 77);
  301.     printf("EMMcopyto() succeeded.\n");
  302.     TESTTAILER();
  303.  
  304.     /* restore EMS pattern */
  305.     test_EMMmappage(0, handle, 0);
  306.     FMEMSET(frameptr[0], 0, 16384);
  307.  
  308.     /* test copy of odd number of bytes to even offset */
  309.     TESTHEADER();
  310.     printf("Calling EMMcopyto() to copy 77 bytes to even offset.\n");
  311.     status = EMMcopyto(77L, (UCF *) testbuf, handle, 498L);
  312.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  313.     SRCWORDCHECK(testbuf, 16384);
  314.     test_EMMmappage(0, handle, 0);
  315.     MEMCMP((frameptr[0] + 498), testbuf, 77);
  316.     ZEROCHECK(frameptr[0], 498);
  317.     ZEROCHECK((frameptr[0] + 498 + 77), ((16384 - 498) - 77));
  318.     printf("EMMcopyto() succeeded.\n");
  319.     TESTTAILER();
  320.  
  321.     /* restore EMS pattern */
  322.     test_EMMmappage(0, handle, 0);
  323.     FMEMSET(frameptr[0], 0, 16384);
  324.  
  325.     /* test copy of odd number of bytes to odd offset */
  326.     TESTHEADER();
  327.     printf("Calling EMMcopyto() to copy 77 bytes to odd offset.\n");
  328.     status = EMMcopyto(77L, (UCF *) testbuf, handle, 777L);
  329.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  330.     SRCWORDCHECK(testbuf, 16384);
  331.     test_EMMmappage(0, handle, 0);
  332.     MEMCMP((frameptr[0] + 777), testbuf, 77);
  333.     ZEROCHECK(frameptr[0], 777);
  334.     ZEROCHECK((frameptr[0] + 777 + 77), ((16384 - 777) - 77));
  335.     printf("EMMcopyto() succeeded.\n");
  336.     TESTTAILER();
  337.  
  338.     /* restore EMS pattern */
  339.     test_EMMmappage(0, handle, 0);
  340.     FMEMSET(frameptr[0], 0, 16384);
  341.  
  342.     /* test copy of odd number of bytes to offset just before end */
  343.     TESTHEADER();
  344.     printf(
  345.          "Calling EMMcopyto() to copy 77 bytes to just before end of page.\n");
  346.     status = EMMcopyto(77L, (UCF *) testbuf, handle, (16384L - 77L));
  347.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  348.     SRCWORDCHECK(testbuf, 16384);
  349.     test_EMMmappage(0, handle, 0);
  350.     MEMCMP((frameptr[0] + (16384 - 77)), testbuf, 77);
  351.     ZEROCHECK(frameptr[0], (16384 - 77));
  352.     printf("EMMcopyto() succeeded.\n");
  353.     TESTTAILER();
  354.  
  355.     /* restore EMS pattern */
  356.     test_EMMmappage(0, handle, 0);
  357.     FMEMSET(frameptr[0], 0, 16384);
  358.  
  359.     /* copy entire page by words */
  360.     TESTHEADER();
  361.     printf("Calling EMMcopyto() to fill EMS page in chunks of 2 bytes.\n");
  362.     totticks = 0L;
  363.     for (loop = 0; loop < 16384; loop += 2)
  364.     {
  365.         ticks = get_tick();
  366.         status = EMMcopyto(2L, (UCF *) (testbuf + loop), handle,
  367.                                                          (unsigned long) loop);
  368.         totticks += (get_tick() - ticks);
  369.         TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  370.     }
  371.     SRCWORDCHECK(testbuf, 16384);
  372.     test_EMMmappage(0, handle, 0);
  373.     MEMCMP(frameptr[0], testbuf, 16384);
  374.     printf("EMMcopyto() succeeded, took about %lu ticks.\n", totticks);
  375.     TESTTAILER();
  376.  
  377.     /* restore EMS pattern */
  378.     test_EMMmappage(0, handle, 0);
  379.     FMEMSET(frameptr[0], 0, 16384);
  380.  
  381.     /* copy entire page at once */
  382.     TESTHEADER();
  383.     printf("Calling EMMcopyto() to copy entire page at once.\n");
  384.     ticks = get_tick();
  385.     status = EMMcopyto(16384L, (UCF *) testbuf, handle, 0L);
  386.     ticks = get_tick() - ticks;
  387.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  388.     SRCWORDCHECK(testbuf, 16384);
  389.     test_EMMmappage(0, handle, 0);
  390.     MEMCMP(frameptr[0], testbuf, 16384);
  391.     printf("EMMcopyto() succeeded, took about %lu ticks.\n", ticks);
  392.     TESTTAILER();
  393.  
  394.  
  395.     /* fill EMS page with incrementing word pattern */
  396.     test_EMMmappage(0, handle, 0);
  397.     farincwordfill(frameptr[0], 16384);
  398.  
  399.     /* fill test buffer with a different pattern */
  400.     FMEMSET((UCF *) testbuf, 0, 16384);
  401.  
  402.     /* try a bad copy first */
  403.     TESTHEADER();
  404.     printf("Calling EMMcopyfrom() with bad offset.\n");
  405.     printf("Should fail.\n");
  406.     status = EMMcopyfrom(5L, handle, 20000L, (UCF *) testbuf);
  407.     nofailcheck("EMMcopyfrom()", status, testbuf, handle, 0);
  408.     weirdretchk("EMMcopyfrom()", status, testbuf, handle, 0);
  409.     weirdcodechk("EMMcopyfrom()", EMM_BADOFFSET, testbuf, handle, 0);
  410.     test_EMMmappage(0, handle, 0);
  411.     SRCWORDCHECK(frameptr[0], 16384);
  412.     ZEROCHECK(testbuf, 16384);
  413.     printf("EMMcopyfrom() failed OK.\n");
  414.     TESTTAILER();
  415.  
  416.     /* and another */
  417.     TESTHEADER();
  418.     printf("Calling EMMcopyfrom() with block that runs off end of EMS.\n");
  419.     printf("Should fail.\n");
  420.     status = EMMcopyfrom(500L, handle, 16000L, (UCF *) testbuf);
  421.     nofailcheck("EMMcopyfrom()", status, testbuf, handle, 0);
  422.     weirdretchk("EMMcopyfrom()", status, testbuf, handle, 0);
  423.     weirdcodechk("EMMcopyfrom()", EMM_BADOFFSET, testbuf, handle, 0);
  424.     test_EMMmappage(0, handle, 0);
  425.     SRCWORDCHECK(frameptr[0], 16384);
  426.     ZEROCHECK(testbuf, 16384);
  427.     printf("EMMcopyfrom() failed OK.\n");
  428.     TESTTAILER();
  429.  
  430.     /* test zero-length copy */
  431.     TESTHEADER();
  432.     printf("Calling EMMcopyfrom() with zero-length source block.\n");
  433.     printf("Should succeed.\n");
  434.     status = EMMcopyfrom(0L, handle, 0L, (UCF *) testbuf);
  435.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  436.     test_EMMmappage(0, handle, 0);
  437.     SRCWORDCHECK(frameptr[0], 16384);
  438.     ZEROCHECK(testbuf, 16384);
  439.     printf("EMMcopyfrom() succeeded.\n");
  440.     TESTTAILER();
  441.  
  442.     /* test copy of even number of bytes to 0 offset */
  443.     TESTHEADER();
  444.     printf("Calling EMMcopyfrom() to copy 50 bytes to offset 0.\n");
  445.     status = EMMcopyfrom(50L, handle, 0L, (UCF *) testbuf);
  446.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  447.     test_EMMmappage(0, handle, 0);
  448.     SRCWORDCHECK(frameptr[0], 16384);
  449.     CPYWORDCHECK(testbuf, 50);
  450.     ZEROCHECK((testbuf + 50), 16384 - 50);
  451.     printf("EMMcopyfrom() succeeded.\n");
  452.     TESTTAILER();
  453.  
  454.     /* restore destination pattern */
  455.     FMEMSET((UCF *) testbuf, 0, 16384);
  456.  
  457.     /* test copy of even number of bytes to even offset */
  458.     TESTHEADER();
  459.     printf("Calling EMMcopyfrom() to copy 50 bytes to even offset.\n");
  460.     status = EMMcopyfrom(50L, handle, 0L, (UCF *) (testbuf + 498));
  461.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  462.     test_EMMmappage(0, handle, 0);
  463.     SRCWORDCHECK(frameptr[0], 16384);
  464.     CPYWORDCHECK((testbuf + 498), 50);
  465.     ZEROCHECK(testbuf, 498);
  466.     ZEROCHECK((testbuf + 498 + 50), ((16384 - 498) - 50));
  467.     printf("EMMcopyfrom() succeeded.\n");
  468.     TESTTAILER();
  469.  
  470.     /* restore destination pattern */
  471.     FMEMSET((UCF *) testbuf, 0, 16384);
  472.  
  473.     /* test copy of even number of bytes to odd offset */
  474.     TESTHEADER();
  475.     printf("Calling EMMcopyfrom() to copy 50 bytes to odd offset.\n");
  476.     status = EMMcopyfrom(50L, handle, 0L, (UCF *) (testbuf + 777));
  477.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  478.     test_EMMmappage(0, handle, 0);
  479.     SRCWORDCHECK(frameptr[0], 16384);
  480.     CPYWORDCHECK((testbuf + 777), 50);
  481.     ZEROCHECK(testbuf, 777);
  482.     ZEROCHECK((testbuf + 777 + 50), ((16384 - 777) - 50));
  483.     printf("EMMcopyfrom() succeeded.\n");
  484.     TESTTAILER();
  485.  
  486.     /* restore destination pattern */
  487.     FMEMSET((UCF *) testbuf, 0, 16384);
  488.  
  489.     /* test copy of even number of bytes to offset just before end */
  490.     TESTHEADER();
  491.     printf(
  492.          "Calling EMMcopyfrom() to copy 50 bytes to just before end of page.\n");
  493.     status = EMMcopyfrom(50L, handle, 0L, (UCF *) (testbuf + (16384 - 50)));
  494.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  495.     test_EMMmappage(0, handle, 0);
  496.     SRCWORDCHECK(frameptr[0], 16384);
  497.     CPYWORDCHECK((testbuf + (16384 - 50)), 50);
  498.     ZEROCHECK(testbuf, (16384 - 50));
  499.     printf("EMMcopyfrom() succeeded.\n");
  500.     TESTTAILER();
  501.  
  502.     /* restore destination pattern */
  503.     FMEMSET((UCF *) testbuf, 0, 16384);
  504.  
  505.     /* test copy of odd number of bytes to 0 offset */
  506.     TESTHEADER();
  507.     printf("Calling EMMcopyfrom() to copy 77 bytes to offset 0.\n");
  508.     status = EMMcopyfrom(77L, handle, 0L, (UCF *) testbuf);
  509.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  510.     test_EMMmappage(0, handle, 0);
  511.     SRCWORDCHECK(frameptr[0], 16384);
  512.     MEMCMP(testbuf, frameptr[0], 77);
  513.     ZEROCHECK((testbuf + 77), 16384 - 77);
  514.     printf("EMMcopyfrom() succeeded.\n");
  515.     TESTTAILER();
  516.  
  517.     /* restore destination pattern */
  518.     FMEMSET((UCF *) testbuf, 0, 16384);
  519.  
  520.     /* test copy of odd number of bytes to even offset */
  521.     TESTHEADER();
  522.     printf("Calling EMMcopyfrom() to copy 77 bytes to even offset.\n");
  523.     status = EMMcopyfrom(77L, handle, 0L, (UCF *) (testbuf + 498));
  524.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  525.     test_EMMmappage(0, handle, 0);
  526.     SRCWORDCHECK(frameptr[0], 16384);
  527.     MEMCMP((testbuf + 498), frameptr[0], 77);
  528.     ZEROCHECK(testbuf, 498);
  529.     ZEROCHECK((testbuf + 498 + 77), ((16384 - 498) - 77));
  530.     printf("EMMcopyfrom() succeeded.\n");
  531.     TESTTAILER();
  532.  
  533.     /* restore destination pattern */
  534.     FMEMSET((UCF *) testbuf, 0, 16384);
  535.  
  536.     /* test copy of odd number of bytes to odd offset */
  537.     TESTHEADER();
  538.     printf("Calling EMMcopyfrom() to copy 77 bytes to odd offset.\n");
  539.     status = EMMcopyfrom(77L, handle, 0L, (UCF *) (testbuf + 777));
  540.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  541.     test_EMMmappage(0, handle, 0);
  542.     SRCWORDCHECK(frameptr[0], 16384);
  543.     MEMCMP((testbuf + 777), frameptr[0], 77);
  544.     ZEROCHECK(testbuf, 777);
  545.     ZEROCHECK((testbuf + 777 + 77), ((16384 - 777) - 77));
  546.     printf("EMMcopyfrom() succeeded.\n");
  547.     TESTTAILER();
  548.  
  549.     /* restore destination pattern */
  550.     FMEMSET((UCF *) testbuf, 0, 16384);
  551.  
  552.     /* test copy of odd number of bytes to offset just before end */
  553.     TESTHEADER();
  554.     printf(
  555.        "Calling EMMcopyfrom() to copy 77 bytes to just before end of page.\n");
  556.     status = EMMcopyfrom(77L, handle, 0L, (UCF *) (testbuf + (16384 - 77)));
  557.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  558.     test_EMMmappage(0, handle, 0);
  559.     SRCWORDCHECK(frameptr[0], 16384);
  560.     MEMCMP((testbuf + (16384 - 77)), frameptr[0], 77);
  561.     ZEROCHECK(testbuf, (16384 - 77));
  562.     printf("EMMcopyfrom() succeeded.\n");
  563.     TESTTAILER();
  564.  
  565.     /* restore destination pattern */
  566.     FMEMSET((UCF *) testbuf, 0, 16384);
  567.  
  568.     /* copy entire page by words */
  569.     TESTHEADER();
  570.     printf("Calling EMMcopyfrom() to fill buffer in chunks of 2 bytes.\n");
  571.     totticks = 0L;
  572.     for (loop = 0; loop < 16384; loop += 2)
  573.     {
  574.         ticks = get_tick();
  575.         status = EMMcopyfrom(2L, handle, (unsigned long) loop,
  576.                                                      (UCF *) (testbuf + loop));
  577.         totticks += (get_tick() - ticks);
  578.         TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  579.     }
  580.     test_EMMmappage(0, handle, 0);
  581.     SRCWORDCHECK(frameptr[0], 16384);
  582.     MEMCMP(testbuf, frameptr[0], 16384);
  583.     printf("EMMcopyfrom() succeeded, took about %lu ticks.\n", totticks);
  584.     TESTTAILER();
  585.  
  586.     /* restore destination pattern */
  587.     FMEMSET((UCF *) testbuf, 0, 16384);
  588.  
  589.     /* copy entire page at once */
  590.     TESTHEADER();
  591.     printf("Calling EMMcopyfrom() to copy entire page at once.\n");
  592.     ticks = get_tick();
  593.     status = EMMcopyfrom(16384L, handle, 0L, (UCF *) testbuf);
  594.     ticks = get_tick() - ticks;
  595.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  596.     test_EMMmappage(0, handle, 0);
  597.     SRCWORDCHECK(frameptr[0], 16384);
  598.     MEMCMP(testbuf, frameptr[0], 16384);
  599.     printf("EMMcopyfrom() succeeded, took about %lu ticks.\n", ticks);
  600.     TESTTAILER();
  601.  
  602.     /* clean up */
  603.     test_EMMfree(handle);
  604.     free(testbuf);
  605.  
  606.     return;
  607. } /* end of do_nshortcopy_tests() */
  608.  
  609.  
  610. /***************************************************************************
  611. *   FUNCTION: DO_ISHORTCOPY_TESTS  (STATIC)                                *
  612. *                                                                          *
  613. *   DESCRIPTION:                                                           *
  614. *                                                                          *
  615. *       Tests EMSLIB functions _EMMicopyto() and _EMMicopyfrom() with      *
  616. *       copies shorter than one EMS page ( <= 16384 bytes ).               *
  617. *                                                                          *
  618. *   ENTRY:                                                                 *
  619. *                                                                          *
  620. *       Void.                                                              *
  621. *                                                                          *
  622. *   EXIT:                                                                  *
  623. *                                                                          *
  624. *       Void.                                                              *
  625. *                                                                          *
  626. *   CONSTRAINTS/SIDE EFFECTS:                                              *
  627. *                                                                          *
  628. ***************************************************************************/
  629. static void do_ishortcopy_tests(void)
  630. {
  631.     unsigned char *testbuf;
  632.     int handle;
  633.     int status;
  634.     unsigned long ticks, totticks;
  635.     int loop;
  636.  
  637.     /* allocate memory to test against */
  638.     testbuf = (unsigned char *) malloc(16384);
  639.     if (testbuf == (unsigned char *) NULL)
  640.     {
  641.         printf("Cannot allocate test memory. Aborting.\n");
  642.         exit(1);
  643.     }
  644.  
  645.     /* now allocate a page of EMS to test with */
  646.     handle = test_EMMallocpages(1);
  647.  
  648.     /* fill test buffer with incrementing word pattern */
  649.     farincwordfill((UCF *) testbuf, 16384);
  650.  
  651.     /* fill EMS page with a different pattern */
  652.     test_EMMmappage(0, handle, 0);
  653.     FMEMSET(frameptr[0], 0, 16384);
  654.  
  655.     /* try a bad copy first */
  656.     TESTHEADER();
  657.     printf("Calling _EMMicopyto() with bad offset.\n");
  658.     printf("Should fail.\n");
  659.     status = EMMicopyto(5L, 2, 2, (UCF *) testbuf, handle, 20000L);
  660.     nofailcheck("_EMMicopyto()", status, testbuf, handle, 0);
  661.     weirdretchk("_EMMicopyto()", status, testbuf, handle, 0);
  662.     weirdcodechk("_EMMicopyto()", EMM_BADOFFSET, testbuf, handle, 0);
  663.     SRCWORDCHECK(testbuf, 16384);
  664.     test_EMMmappage(0, handle, 0);
  665.     ZEROCHECK(frameptr[0], 16384);
  666.     printf("_EMMicopyto() failed OK.\n");
  667.     TESTTAILER();
  668.  
  669.     /* and another */
  670.     TESTHEADER();
  671.     printf("Calling _EMMicopyto() with block that runs off end of EMS.\n");
  672.     printf("Should fail.\n");
  673.     status = EMMicopyto(500L, 2, 2, (UCF *) testbuf, handle, 16000L);
  674.     nofailcheck("_EMMicopyto()", status, testbuf, handle, 0);
  675.     weirdretchk("_EMMicopyto()", status, testbuf, handle, 0);
  676.     weirdcodechk("_EMMicopyto()", EMM_BADOFFSET, testbuf, handle, 0);
  677.     SRCWORDCHECK(testbuf, 16384);
  678.     test_EMMmappage(0, handle, 0);
  679.     ZEROCHECK(frameptr[0], 16384);
  680.     printf("_EMMicopyto() failed OK.\n");
  681.     TESTTAILER();
  682.  
  683.     /* and another */
  684.     TESTHEADER();
  685.     printf("Calling _EMMicopyto() with element size > 16384 bytes.\n");
  686.     printf("Should fail.\n");
  687.     status = EMMicopyto(2L, 20000, 2, (UCF *) testbuf, handle, 0L);
  688.     nofailcheck("_EMMicopyto()", status, testbuf, handle, 0);
  689.     weirdretchk("_EMMicopyto()", status, testbuf, handle, 0);
  690.     weirdcodechk("_EMMicopyto()", EMM_ELTOOBIG, testbuf, handle, 0);
  691.     SRCWORDCHECK(testbuf, 16384);
  692.     test_EMMmappage(0, handle, 0);
  693.     ZEROCHECK(frameptr[0], 16384);
  694.     printf("_EMMicopyto() failed OK.\n");
  695.     TESTTAILER();
  696.  
  697.     /* and another */
  698.     TESTHEADER();
  699.     printf("Calling _EMMicopyto() with skip size > 32768 bytes.\n");
  700.     printf("Should fail.\n");
  701.     status = EMMicopyto(2L, 2, 40000U, (UCF *) testbuf, handle, 0L);
  702.     nofailcheck("_EMMicopyto()", status, testbuf, handle, 0);
  703.     weirdretchk("_EMMicopyto()", status, testbuf, handle, 0);
  704.     weirdcodechk("_EMMicopyto()", EMM_SKTOOBIG, testbuf, handle, 0);
  705.     SRCWORDCHECK(testbuf, 16384);
  706.     test_EMMmappage(0, handle, 0);
  707.     ZEROCHECK(frameptr[0], 16384);
  708.     printf("_EMMicopyto() failed OK.\n");
  709.     TESTTAILER();
  710.  
  711.     /* test zero-length copy */
  712.     TESTHEADER();
  713.     printf("Calling _EMMicopyto() with zero elements.\n");
  714.     printf("Should succeed.\n");
  715.     status = EMMicopyto(0L, 2, 2, (UCF *) testbuf, handle, 0L);
  716.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  717.     SRCWORDCHECK(testbuf, 16384);
  718.     test_EMMmappage(0, handle, 0);
  719.     ZEROCHECK(frameptr[0], 16384);
  720.     printf("_EMMicopyto() succeeded.\n");
  721.     TESTTAILER();
  722.  
  723.     /* test zero-length copy differently */
  724.     TESTHEADER();
  725.     printf("Calling _EMMicopyto() with zero-length elements.\n");
  726.     printf("Should succeed.\n");
  727.     status = EMMicopyto(50L, 0, 2, (UCF *) testbuf, handle, 0L);
  728.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  729.     SRCWORDCHECK(testbuf, 16384);
  730.     test_EMMmappage(0, handle, 0);
  731.     ZEROCHECK(frameptr[0], 16384);
  732.     printf("_EMMicopyto() succeeded.\n");
  733.     TESTTAILER();
  734.  
  735.     /* test skip size of 0 */
  736.     TESTHEADER();
  737.     printf("Calling _EMMicopyto() with zero source and dest skip.\n");
  738.     printf("Should succeed.\n");
  739.     status = EMMicopyto(50L, 2, 0, (UCF *) testbuf, handle, 0L);
  740.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  741.     SRCWORDCHECK(testbuf, 16384);
  742.     test_EMMmappage(0, handle, 0);
  743.     CPYWORDCHECK(frameptr[0], 100);
  744.     ZEROCHECK((frameptr[0] + 100), (16384 - 100));
  745.     printf("_EMMicopyto() succeeded.\n");
  746.     TESTTAILER();
  747.  
  748.     /* restore destination pattern */
  749.     test_EMMmappage(0, handle, 0);
  750.     FMEMSET(frameptr[0], 0, 16384);
  751.  
  752.     /* test copy even same skip, even size */
  753.     TESTHEADER();
  754.     printf("Calling _EMMicopyto() size, skips even,.\n");
  755.     printf("Should succeed.\n");
  756.     status = EMMicopyto(25L, 2, 4, (UCF *) testbuf, handle, 0L);
  757.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  758.     status = EMMicopyto(25L, 4, 2, (UCF *) (testbuf + 2), handle, 2L);
  759.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  760.     SRCWORDCHECK(testbuf, 16384);
  761.     test_EMMmappage(0, handle, 0);
  762.     CPYWORDCHECK(frameptr[0], 150);
  763.     ZEROCHECK((frameptr[0] + 150), (16384 - 150));
  764.     printf("_EMMicopyto() succeeded.\n");
  765.     TESTTAILER();
  766.  
  767.     /* restore destination pattern */
  768.     test_EMMmappage(0, handle, 0);
  769.     FMEMSET(frameptr[0], 0, 16384);
  770.  
  771.     /* test copy of size even, skip same odd and size odd, skip same even */
  772.     printf("Calling _EMMicopyto() with size even/skips odd & size odd/skips ");
  773.     printf("even.\nShould succeed.\n");
  774.     status = EMMicopyto(25L, 2, 3, (UCF *) testbuf, handle, 0L);
  775.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  776.     status = EMMicopyto(25L, 3, 2, (UCF *) (testbuf + 2), handle, 2L);
  777.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  778.     SRCWORDCHECK(testbuf, 16384);
  779.     test_EMMmappage(0, handle, 0);
  780.     MEMCMP(frameptr[0], testbuf, 125);
  781.     ZEROCHECK((frameptr[0] + 125), (16384 - 125));
  782.     printf("_EMMicopyto() succeeded.\n");
  783.     TESTTAILER();
  784.  
  785.     /* restore destination pattern */
  786.     test_EMMmappage(0, handle, 0);
  787.     FMEMSET(frameptr[0], 0, 16384);
  788.  
  789.     /* test copy of skip same odd, size odd */
  790.     TESTHEADER();
  791.     printf("Calling _EMMicopyto() with skips and size odd.\n");
  792.     printf("Should succeed.\n");
  793.     status = EMMicopyto(25L, 3, 7, (UCF *) testbuf, handle, 0L);
  794.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  795.     status = EMMicopyto(25L, 7, 3, (UCF *) (testbuf + 3), handle, 3L);
  796.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  797.     SRCWORDCHECK(testbuf, 16384);
  798.     test_EMMmappage(0, handle, 0);
  799.     CPYWORDCHECK(frameptr[0], 250);
  800.     ZEROCHECK((frameptr[0] + 250), (16384 - 250));
  801.     printf("_EMMicopyto() succeeded.\n");
  802.     TESTTAILER();
  803.  
  804.     /* restore destination pattern */
  805.     test_EMMmappage(0, handle, 0);
  806.     FMEMSET(frameptr[0], 0, 16384);
  807.  
  808.     /* copy entire page in two passes */
  809.     TESTHEADER();
  810.     printf("Calling _EMMicopyto() to copy page in two passes, by words.\n");
  811.     totticks = 0L;
  812.     ticks = get_tick();
  813.     status = EMMicopyto(4096L, 2, 2, (UCF *) testbuf, handle, 0L);
  814.     totticks += (get_tick() - ticks);
  815.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  816.     ticks = get_tick();
  817.     status = EMMicopyto(4096L, 2, 2, (UCF *) (testbuf + 2), handle, 2L);
  818.     totticks += (get_tick() - ticks);
  819.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  820.     SRCWORDCHECK(testbuf, 16384);
  821.     test_EMMmappage(0, handle, 0);
  822.     MEMCMP(frameptr[0], testbuf, 16384);
  823.     printf("_EMMicopyto() succeeded, took about %lu ticks.\n", totticks);
  824.     TESTTAILER();
  825.  
  826.     /* restore destination pattern */
  827.     test_EMMmappage(0, handle, 0);
  828.     FMEMSET(frameptr[0], 0, 16384);
  829.  
  830.     /* copy entire page, interleaving */
  831.     TESTHEADER();
  832.     printf(
  833.        "Calling _EMMicopyto() to copy page in two passes, skips different.\n");
  834.     status = _EMMicopyto(4096L, 2, 2, (UCF *) testbuf, handle, 0L, 0);
  835.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  836.     status = _EMMicopyto(4096L, 2, 2, (UCF *) (testbuf + 2), handle, 8192L, 0);
  837.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  838.     SRCWORDCHECK(testbuf, 16384);
  839.     test_EMMmappage(0, handle, 0);
  840.     for (loop = 0; loop < 8192; loop += 2)
  841.     {
  842.         if ((*((unsigned int far *)(frameptr[0] + loop)) != loop) ||
  843.             (*((unsigned int far *)(frameptr[0] + loop + 8192)) != (loop + 1)))
  844.         {
  845.             printf("_EMMicopyto() corrupted copied bytes.\n");
  846.             free(testbuf);
  847.             test_EMMfree(handle);
  848.             exit(3);
  849.         }
  850.     }
  851.     TESTTAILER();
  852.  
  853.  
  854.     /* fill EMS page with incrementing word pattern */
  855.     test_EMMmappage(0, handle, 0);
  856.     farincwordfill(frameptr[0], 16384);
  857.  
  858.     /* fill test buffer with a different pattern */
  859.     FMEMSET((UCF *) testbuf, 0, 16384);
  860.  
  861.     /* try a bad copy first */
  862.     TESTHEADER();
  863.     printf("Calling _EMMicopyfrom() with bad offset.\n");
  864.     printf("Should fail.\n");
  865.     status = EMMicopyfrom(5L, 2, 2, handle, 20000L, (UCF *) testbuf);
  866.     nofailcheck("_EMMicopyfrom()", status, testbuf, handle, 0);
  867.     weirdretchk("_EMMicopyfrom()", status, testbuf, handle, 0);
  868.     weirdcodechk("_EMMicopyfrom()", EMM_BADOFFSET, testbuf, handle, 0);
  869.     test_EMMmappage(0, handle, 0);
  870.     SRCWORDCHECK(frameptr[0], 16384);
  871.     ZEROCHECK(testbuf, 16384);
  872.     printf("_EMMicopyfrom() failed OK.\n");
  873.     TESTTAILER();
  874.  
  875.     /* and another */
  876.     TESTHEADER();
  877.     printf("Calling _EMMicopyfrom() with block that runs off end of EMS.\n");
  878.     printf("Should fail.\n");
  879.     status = EMMicopyfrom(500L, 2, 2, handle, 16000L, (UCF *) testbuf);
  880.     nofailcheck("_EMMicopyfrom()", status, testbuf, handle, 0);
  881.     weirdretchk("_EMMicopyfrom()", status, testbuf, handle, 0);
  882.     weirdcodechk("_EMMicopyfrom()", EMM_BADOFFSET, testbuf, handle, 0);
  883.     test_EMMmappage(0, handle, 0);
  884.     SRCWORDCHECK(frameptr[0], 16384);
  885.     ZEROCHECK(testbuf, 16384);
  886.     printf("_EMMicopyfrom() failed OK.\n");
  887.     TESTTAILER();
  888.  
  889.     /* and another */
  890.     TESTHEADER();
  891.     printf("Calling _EMMicopyfrom() with element size > 16384 bytes.\n");
  892.     printf("Should fail.\n");
  893.     status = EMMicopyfrom(2L, 20000, 2, handle, 0L, (UCF *) testbuf);
  894.     nofailcheck("_EMMicopyfrom()", status, testbuf, handle, 0);
  895.     weirdretchk("_EMMicopyfrom()", status, testbuf, handle, 0);
  896.     weirdcodechk("_EMMicopyfrom()", EMM_ELTOOBIG, testbuf, handle, 0);
  897.     test_EMMmappage(0, handle, 0);
  898.     SRCWORDCHECK(frameptr[0], 16384);
  899.     ZEROCHECK(testbuf, 16384);
  900.     printf("_EMMicopyfrom() failed OK.\n");
  901.     TESTTAILER();
  902.  
  903.     /* and another */
  904.     TESTHEADER();
  905.     printf("Calling _EMMicopyfrom() with skip size > 32768 bytes.\n");
  906.     printf("Should fail.\n");
  907.     status = EMMicopyfrom(2L, 2, 40000U, handle, 0L, (UCF *) testbuf);
  908.     nofailcheck("_EMMicopyfrom()", status, testbuf, handle, 0);
  909.     weirdretchk("_EMMicopyfrom()", status, testbuf, handle, 0);
  910.     weirdcodechk("_EMMicopyfrom()", EMM_SKTOOBIG, testbuf, handle, 0);
  911.     test_EMMmappage(0, handle, 0);
  912.     SRCWORDCHECK(frameptr[0], 16384);
  913.     ZEROCHECK(testbuf, 16384);
  914.     printf("_EMMicopyfrom() failed OK.\n");
  915.     TESTTAILER();
  916.  
  917.     /* test zero-length copy */
  918.     TESTHEADER();
  919.     printf("Calling _EMMicopyfrom() with zero elements.\n");
  920.     printf("Should succeed.\n");
  921.     status = EMMicopyfrom(0L, 2, 2, handle, 0L, (UCF *) testbuf);
  922.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  923.     test_EMMmappage(0, handle, 0);
  924.     SRCWORDCHECK(frameptr[0], 16384);
  925.     ZEROCHECK(testbuf, 16384);
  926.     printf("_EMMicopyfrom() succeeded.\n");
  927.     TESTTAILER();
  928.  
  929.     /* test zero-length copy differently */
  930.     TESTHEADER();
  931.     printf("Calling _EMMicopyfrom() with zero-length elements.\n");
  932.     printf("Should succeed.\n");
  933.     status = EMMicopyfrom(50L, 0, 2, handle, 0L, (UCF *) testbuf);
  934.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  935.     test_EMMmappage(0, handle, 0);
  936.     SRCWORDCHECK(frameptr[0], 16384);
  937.     ZEROCHECK(testbuf, 16384);
  938.     printf("_EMMicopyfrom() succeeded.\n");
  939.     TESTTAILER();
  940.  
  941.     /* test skip size of 0 */
  942.     TESTHEADER();
  943.     printf("Calling _EMMicopyfrom() with zero source and dest skip.\n");
  944.     printf("Should succeed.\n");
  945.     status = EMMicopyfrom(50L, 2, 0, handle, 0L, (UCF *) testbuf);
  946.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  947.     test_EMMmappage(0, handle, 0);
  948.     SRCWORDCHECK(frameptr[0], 16384);
  949.     CPYWORDCHECK(testbuf, 100);
  950.     ZEROCHECK((testbuf + 100), (16384 - 100));
  951.     printf("_EMMicopyfrom() succeeded.\n");
  952.     TESTTAILER();
  953.  
  954.     /* restore destination pattern */
  955.     FMEMSET((UCF *) testbuf, 0, 16384);
  956.  
  957.     /* test copy even same skip, even size */
  958.     TESTHEADER();
  959.     printf("Calling _EMMicopyfrom() with size, skips even.\n");
  960.     printf("Should succeed.\n");
  961.     status = EMMicopyfrom(25L, 2, 4, handle, 0L, (UCF *) testbuf);
  962.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  963.     status = EMMicopyfrom(25L, 4, 2, handle, 2L, (UCF *) (testbuf + 2));
  964.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  965.     test_EMMmappage(0, handle, 0);
  966.     SRCWORDCHECK(frameptr[0], 16384);
  967.     CPYWORDCHECK(testbuf, 150);
  968.     ZEROCHECK((testbuf + 150), (16384 - 150));
  969.     printf("_EMMicopyfrom() succeeded.\n");
  970.     TESTTAILER();
  971.  
  972.     /* restore destination pattern */
  973.     FMEMSET((UCF *) testbuf, 0, 16384);
  974.  
  975.     /* test copy of size even, skip same odd and size odd, skip same even */
  976.     printf("Calling _EMMicopyfrom() with size even/skips odd & size odd/");
  977.     printf("skips even, offset even.\nShould succeed.\n");
  978.     status = EMMicopyfrom(25L, 2, 3, handle, 0L, (UCF *) testbuf);
  979.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  980.     status = EMMicopyfrom(25L, 3, 2, handle, 2L, (UCF *) (testbuf + 2));
  981.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  982.     test_EMMmappage(0, handle, 0);
  983.     SRCWORDCHECK(frameptr[0], 16384);
  984.     MEMCMP(frameptr[0], testbuf, 125);
  985.     ZEROCHECK((testbuf + 125), (16384 - 125));
  986.     printf("_EMMicopyfrom() succeeded.\n");
  987.     TESTTAILER();
  988.  
  989.     /* restore destination pattern */
  990.     FMEMSET((UCF *) testbuf, 0, 16384);
  991.  
  992.     /* test copy of skip same odd, size odd */
  993.     TESTHEADER();
  994.     printf("Calling _EMMicopyfrom() with skips and size odd.\n");
  995.     printf("Should succeed.\n");
  996.     status = EMMicopyfrom(25L, 3, 7, handle, 0L, (UCF *) testbuf);
  997.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  998.     status = EMMicopyfrom(25L, 7, 3, handle, 3L, (UCF *) (testbuf + 3));
  999.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1000.     test_EMMmappage(0, handle, 0);
  1001.     SRCWORDCHECK(frameptr[0], 16384);
  1002.     CPYWORDCHECK(testbuf, 250);
  1003.     ZEROCHECK((testbuf + 250), (16384 - 250));
  1004.     printf("_EMMicopyfrom() succeeded.\n");
  1005.     TESTTAILER();
  1006.  
  1007.     /* restore destination pattern */
  1008.     FMEMSET((UCF *) testbuf, 0, 16384);
  1009.  
  1010.     /* copy entire page in two passes */
  1011.     TESTHEADER();
  1012.     printf("Calling _EMMicopyfrom() to copy page in two passes, by words.\n");
  1013.     totticks = 0L;
  1014.     ticks = get_tick();
  1015.     status = EMMicopyfrom(4096L, 2, 2, handle, 0L, (UCF *) testbuf);
  1016.     totticks += (get_tick() - ticks);
  1017.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1018.     ticks = get_tick();
  1019.     status = EMMicopyfrom(4096L, 2, 2, handle, 2L, (UCF *) (testbuf + 2));
  1020.     totticks += (get_tick() - ticks);
  1021.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1022.     test_EMMmappage(0, handle, 0);
  1023.     SRCWORDCHECK(frameptr[0], 16384);
  1024.     MEMCMP(testbuf, frameptr[0], 16384);
  1025.     printf("_EMMicopyfrom() succeeded, took about %lu ticks.\n", totticks);
  1026.     TESTTAILER();
  1027.  
  1028.     /* restore destination pattern */
  1029.     FMEMSET((UCF *) testbuf, 0, 16384);
  1030.  
  1031.     /* copy entire page, interleaving */
  1032.     TESTHEADER();
  1033.     printf(
  1034.        "Calling _EMMicopyfrom() to copy page in two passes, skips different.\n");
  1035.     status = _EMMicopyfrom(4096L, 2, 2, handle, 0L, (UCF *) testbuf, 0);
  1036.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1037.     status = _EMMicopyfrom(4096L, 2, 2, handle, 2L, (UCF *) (testbuf+8192), 0);
  1038.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1039.     test_EMMmappage(0, handle, 0);
  1040.     SRCWORDCHECK(frameptr[0], 16384);
  1041.     for (loop = 0; loop < 8192; loop += 2)
  1042.     {
  1043.         if ((*((unsigned int far *)(testbuf + loop)) != loop) ||
  1044.             (*((unsigned int far *)(testbuf + loop + 8192)) != (loop + 1)))
  1045.         {
  1046.             printf("_EMMicopyfrom() corrupted copied bytes.\n");
  1047.             free(testbuf);
  1048.             test_EMMfree(handle);
  1049.             exit(3);
  1050.         }
  1051.     }
  1052.     TESTTAILER();
  1053.  
  1054.  
  1055.     /* clean up */
  1056.     test_EMMfree(handle);
  1057.     free(testbuf);
  1058.  
  1059.     return;
  1060. } /* end of do_ishortcopy_tests() */
  1061.  
  1062.