aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-01-15 17:27:45 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-01-15 17:27:45 +0300
commit0a478564f7ca32e7e5e6e20559149067515082a6 (patch)
treea375cd9ead5b0cb501cbc6f79f57033cb03e4dfa
parentd44b9b23e0ca8b4b80b8e79c6216fc996ad45137 (diff)
downloadlibmicrohttpd-0a478564f7ca32e7e5e6e20559149067515082a6.tar.gz
libmicrohttpd-0a478564f7ca32e7e5e6e20559149067515082a6.zip
test_upgrade{,_large}: simplified stdout,stderr flushing
-rw-r--r--src/microhttpd/test_upgrade.c50
-rw-r--r--src/microhttpd/test_upgrade_large.c24
2 files changed, 46 insertions, 28 deletions
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 17aeba63..68598723 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -164,6 +164,14 @@ _testErrorLog_func (const char *errDesc, const char *funcName, int lineNum)
164#endif 164#endif
165 165
166 166
167static void
168fflush_allstd (void)
169{
170 fflush (stderr);
171 fflush (stdout);
172}
173
174
167static int verbose = 0; 175static int verbose = 0;
168 176
169enum tls_tool 177enum tls_tool
@@ -1433,8 +1441,7 @@ main (int argc,
1433 /* try external select */ 1441 /* try external select */
1434 res = test_upgrade (0, 1442 res = test_upgrade (0,
1435 0); 1443 0);
1436 fflush (stderr); 1444 fflush_allstd ();
1437 fflush (stdout);
1438 error_count += res; 1445 error_count += res;
1439 if (res) 1446 if (res)
1440 fprintf (stderr, 1447 fprintf (stderr,
@@ -1446,8 +1453,7 @@ main (int argc,
1446 /* Try external auto */ 1453 /* Try external auto */
1447 res = test_upgrade (MHD_USE_AUTO, 1454 res = test_upgrade (MHD_USE_AUTO,
1448 0); 1455 0);
1449 fflush (stderr); 1456 fflush_allstd ();
1450 fflush (stdout);
1451 error_count += res; 1457 error_count += res;
1452 if (res) 1458 if (res)
1453 fprintf (stderr, 1459 fprintf (stderr,
@@ -1459,8 +1465,7 @@ main (int argc,
1459#ifdef EPOLL_SUPPORT 1465#ifdef EPOLL_SUPPORT
1460 res = test_upgrade (MHD_USE_EPOLL, 1466 res = test_upgrade (MHD_USE_EPOLL,
1461 0); 1467 0);
1462 fflush (stderr); 1468 fflush_allstd ();
1463 fflush (stdout);
1464 error_count += res; 1469 error_count += res;
1465 if (res) 1470 if (res)
1466 fprintf (stderr, 1471 fprintf (stderr,
@@ -1474,8 +1479,7 @@ main (int argc,
1474 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD 1479 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD
1475 | MHD_USE_THREAD_PER_CONNECTION, 1480 | MHD_USE_THREAD_PER_CONNECTION,
1476 0); 1481 0);
1477 fflush (stderr); 1482 fflush_allstd ();
1478 fflush (stdout);
1479 error_count += res; 1483 error_count += res;
1480 if (res) 1484 if (res)
1481 fprintf (stderr, 1485 fprintf (stderr,
@@ -1487,8 +1491,7 @@ main (int argc,
1487 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD 1491 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD
1488 | MHD_USE_THREAD_PER_CONNECTION, 1492 | MHD_USE_THREAD_PER_CONNECTION,
1489 0); 1493 0);
1490 fflush (stderr); 1494 fflush_allstd ();
1491 fflush (stdout);
1492 error_count += res; 1495 error_count += res;
1493 if (res) 1496 if (res)
1494 fprintf (stderr, 1497 fprintf (stderr,
@@ -1500,8 +1503,7 @@ main (int argc,
1500 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD 1503 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD
1501 | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL, 1504 | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL,
1502 0); 1505 0);
1503 fflush (stderr); 1506 fflush_allstd ();
1504 fflush (stdout);
1505 error_count += res; 1507 error_count += res;
1506 if (res) 1508 if (res)
1507 fprintf (stderr, 1509 fprintf (stderr,
@@ -1514,8 +1516,7 @@ main (int argc,
1514 /* Test different event loops, with and without thread pool */ 1516 /* Test different event loops, with and without thread pool */
1515 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, 1517 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD,
1516 0); 1518 0);
1517 fflush (stderr); 1519 fflush_allstd ();
1518 fflush (stdout);
1519 error_count += res; 1520 error_count += res;
1520 if (res) 1521 if (res)
1521 fprintf (stderr, 1522 fprintf (stderr,
@@ -1525,8 +1526,7 @@ main (int argc,
1525 printf ("PASSED: Upgrade with internal select.\n"); 1526 printf ("PASSED: Upgrade with internal select.\n");
1526 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, 1527 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD,
1527 2); 1528 2);
1528 fflush (stderr); 1529 fflush_allstd ();
1529 fflush (stdout);
1530 error_count += res; 1530 error_count += res;
1531 if (res) 1531 if (res)
1532 fprintf (stderr, 1532 fprintf (stderr,
@@ -1536,8 +1536,7 @@ main (int argc,
1536 printf ("PASSED: Upgrade with internal select with thread pool.\n"); 1536 printf ("PASSED: Upgrade with internal select with thread pool.\n");
1537 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, 1537 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
1538 0); 1538 0);
1539 fflush (stderr); 1539 fflush_allstd ();
1540 fflush (stdout);
1541 error_count += res; 1540 error_count += res;
1542 if (res) 1541 if (res)
1543 fprintf (stderr, 1542 fprintf (stderr,
@@ -1547,8 +1546,7 @@ main (int argc,
1547 printf ("PASSED: Upgrade with internal 'auto'.\n"); 1546 printf ("PASSED: Upgrade with internal 'auto'.\n");
1548 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, 1547 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
1549 2); 1548 2);
1550 fflush (stderr); 1549 fflush_allstd ();
1551 fflush (stdout);
1552 error_count += res; 1550 error_count += res;
1553 if (res) 1551 if (res)
1554 fprintf (stderr, 1552 fprintf (stderr,
@@ -1559,8 +1557,7 @@ main (int argc,
1559#ifdef HAVE_POLL 1557#ifdef HAVE_POLL
1560 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, 1558 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD,
1561 0); 1559 0);
1562 fflush (stderr); 1560 fflush_allstd ();
1563 fflush (stdout);
1564 error_count += res; 1561 error_count += res;
1565 if (res) 1562 if (res)
1566 fprintf (stderr, 1563 fprintf (stderr,
@@ -1570,8 +1567,7 @@ main (int argc,
1570 printf ("PASSED: Upgrade with internal poll.\n"); 1567 printf ("PASSED: Upgrade with internal poll.\n");
1571 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, 1568 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD,
1572 2); 1569 2);
1573 fflush (stderr); 1570 fflush_allstd ();
1574 fflush (stdout);
1575 if (res) 1571 if (res)
1576 fprintf (stderr, 1572 fprintf (stderr,
1577 "FAILED: Upgrade with internal poll with thread pool, return code %d.\n", 1573 "FAILED: Upgrade with internal poll with thread pool, return code %d.\n",
@@ -1582,8 +1578,7 @@ main (int argc,
1582#ifdef EPOLL_SUPPORT 1578#ifdef EPOLL_SUPPORT
1583 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, 1579 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD,
1584 0); 1580 0);
1585 fflush (stderr); 1581 fflush_allstd ();
1586 fflush (stdout);
1587 if (res) 1582 if (res)
1588 fprintf (stderr, 1583 fprintf (stderr,
1589 "FAILED: Upgrade with internal epoll, return code %d.\n", 1584 "FAILED: Upgrade with internal epoll, return code %d.\n",
@@ -1592,8 +1587,7 @@ main (int argc,
1592 printf ("PASSED: Upgrade with internal epoll.\n"); 1587 printf ("PASSED: Upgrade with internal epoll.\n");
1593 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, 1588 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD,
1594 2); 1589 2);
1595 fflush (stderr); 1590 fflush_allstd ();
1596 fflush (stdout);
1597 if (res) 1591 if (res)
1598 fprintf (stderr, 1592 fprintf (stderr,
1599 "FAILED: Upgrade with internal epoll, return code %d.\n", 1593 "FAILED: Upgrade with internal epoll, return code %d.\n",
diff --git a/src/microhttpd/test_upgrade_large.c b/src/microhttpd/test_upgrade_large.c
index 6588f6c0..7c1032cf 100644
--- a/src/microhttpd/test_upgrade_large.c
+++ b/src/microhttpd/test_upgrade_large.c
@@ -328,6 +328,14 @@ _testErrorLog_func (const char *errDesc, const char *funcName, int lineNum)
328#endif 328#endif
329 329
330 330
331static void
332fflush_allstd (void)
333{
334 fflush (stderr);
335 fflush (stdout);
336}
337
338
331static int verbose = 0; 339static int verbose = 0;
332 340
333static struct MHD_itc_ kicker = MHD_ITC_STATIC_INIT_INVALID; 341static struct MHD_itc_ kicker = MHD_ITC_STATIC_INIT_INVALID;
@@ -1625,6 +1633,7 @@ main (int argc,
1625 return 77; 1633 return 77;
1626#endif /* ! HTTPS_SUPPORT */ 1634#endif /* ! HTTPS_SUPPORT */
1627 } 1635 }
1636
1628 /* run tests */ 1637 /* run tests */
1629 if (verbose) 1638 if (verbose)
1630 printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n", 1639 printf ("Starting HTTP \"Upgrade\" tests with %s connections.\n",
@@ -1632,6 +1641,7 @@ main (int argc,
1632 /* try external select */ 1641 /* try external select */
1633 res = test_upgrade (0, 1642 res = test_upgrade (0,
1634 0); 1643 0);
1644 fflush_allstd ();
1635 error_count += res; 1645 error_count += res;
1636 if (res) 1646 if (res)
1637 fprintf (stderr, 1647 fprintf (stderr,
@@ -1639,9 +1649,11 @@ main (int argc,
1639 res); 1649 res);
1640 else if (verbose) 1650 else if (verbose)
1641 printf ("PASSED: Upgrade with external select.\n"); 1651 printf ("PASSED: Upgrade with external select.\n");
1652
1642 /* Try external auto */ 1653 /* Try external auto */
1643 res = test_upgrade (MHD_USE_AUTO, 1654 res = test_upgrade (MHD_USE_AUTO,
1644 0); 1655 0);
1656 fflush_allstd ();
1645 error_count += res; 1657 error_count += res;
1646 if (res) 1658 if (res)
1647 fprintf (stderr, 1659 fprintf (stderr,
@@ -1653,6 +1665,7 @@ main (int argc,
1653#ifdef EPOLL_SUPPORT 1665#ifdef EPOLL_SUPPORT
1654 res = test_upgrade (MHD_USE_EPOLL, 1666 res = test_upgrade (MHD_USE_EPOLL,
1655 0); 1667 0);
1668 fflush_allstd ();
1656 error_count += res; 1669 error_count += res;
1657 if (res) 1670 if (res)
1658 fprintf (stderr, 1671 fprintf (stderr,
@@ -1666,6 +1679,7 @@ main (int argc,
1666 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD 1679 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD
1667 | MHD_USE_THREAD_PER_CONNECTION, 1680 | MHD_USE_THREAD_PER_CONNECTION,
1668 0); 1681 0);
1682 fflush_allstd ();
1669 error_count += res; 1683 error_count += res;
1670 if (res) 1684 if (res)
1671 fprintf (stderr, 1685 fprintf (stderr,
@@ -1677,6 +1691,7 @@ main (int argc,
1677 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD 1691 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD
1678 | MHD_USE_THREAD_PER_CONNECTION, 1692 | MHD_USE_THREAD_PER_CONNECTION,
1679 0); 1693 0);
1694 fflush_allstd ();
1680 error_count += res; 1695 error_count += res;
1681 if (res) 1696 if (res)
1682 fprintf (stderr, 1697 fprintf (stderr,
@@ -1688,6 +1703,7 @@ main (int argc,
1688 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD 1703 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD
1689 | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL, 1704 | MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL,
1690 0); 1705 0);
1706 fflush_allstd ();
1691 error_count += res; 1707 error_count += res;
1692 if (res) 1708 if (res)
1693 fprintf (stderr, 1709 fprintf (stderr,
@@ -1700,6 +1716,7 @@ main (int argc,
1700 /* Test different event loops, with and without thread pool */ 1716 /* Test different event loops, with and without thread pool */
1701 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, 1717 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD,
1702 0); 1718 0);
1719 fflush_allstd ();
1703 error_count += res; 1720 error_count += res;
1704 if (res) 1721 if (res)
1705 fprintf (stderr, 1722 fprintf (stderr,
@@ -1709,6 +1726,7 @@ main (int argc,
1709 printf ("PASSED: Upgrade with internal select.\n"); 1726 printf ("PASSED: Upgrade with internal select.\n");
1710 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD, 1727 res = test_upgrade (MHD_USE_INTERNAL_POLLING_THREAD,
1711 2); 1728 2);
1729 fflush_allstd ();
1712 error_count += res; 1730 error_count += res;
1713 if (res) 1731 if (res)
1714 fprintf (stderr, 1732 fprintf (stderr,
@@ -1718,6 +1736,7 @@ main (int argc,
1718 printf ("PASSED: Upgrade with internal select with thread pool.\n"); 1736 printf ("PASSED: Upgrade with internal select with thread pool.\n");
1719 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, 1737 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
1720 0); 1738 0);
1739 fflush_allstd ();
1721 error_count += res; 1740 error_count += res;
1722 if (res) 1741 if (res)
1723 fprintf (stderr, 1742 fprintf (stderr,
@@ -1727,6 +1746,7 @@ main (int argc,
1727 printf ("PASSED: Upgrade with internal 'auto'.\n"); 1746 printf ("PASSED: Upgrade with internal 'auto'.\n");
1728 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD, 1747 res = test_upgrade (MHD_USE_AUTO | MHD_USE_INTERNAL_POLLING_THREAD,
1729 2); 1748 2);
1749 fflush_allstd ();
1730 error_count += res; 1750 error_count += res;
1731 if (res) 1751 if (res)
1732 fprintf (stderr, 1752 fprintf (stderr,
@@ -1737,6 +1757,7 @@ main (int argc,
1737#ifdef HAVE_POLL 1757#ifdef HAVE_POLL
1738 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, 1758 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD,
1739 0); 1759 0);
1760 fflush_allstd ();
1740 error_count += res; 1761 error_count += res;
1741 if (res) 1762 if (res)
1742 fprintf (stderr, 1763 fprintf (stderr,
@@ -1746,6 +1767,7 @@ main (int argc,
1746 printf ("PASSED: Upgrade with internal poll.\n"); 1767 printf ("PASSED: Upgrade with internal poll.\n");
1747 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD, 1768 res = test_upgrade (MHD_USE_POLL_INTERNAL_THREAD,
1748 2); 1769 2);
1770 fflush_allstd ();
1749 if (res) 1771 if (res)
1750 fprintf (stderr, 1772 fprintf (stderr,
1751 "FAILED: Upgrade with internal poll with thread pool, return code %d.\n", 1773 "FAILED: Upgrade with internal poll with thread pool, return code %d.\n",
@@ -1756,6 +1778,7 @@ main (int argc,
1756#ifdef EPOLL_SUPPORT 1778#ifdef EPOLL_SUPPORT
1757 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, 1779 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD,
1758 0); 1780 0);
1781 fflush_allstd ();
1759 if (res) 1782 if (res)
1760 fprintf (stderr, 1783 fprintf (stderr,
1761 "FAILED: Upgrade with internal epoll, return code %d.\n", 1784 "FAILED: Upgrade with internal epoll, return code %d.\n",
@@ -1764,6 +1787,7 @@ main (int argc,
1764 printf ("PASSED: Upgrade with internal epoll.\n"); 1787 printf ("PASSED: Upgrade with internal epoll.\n");
1765 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD, 1788 res = test_upgrade (MHD_USE_EPOLL_INTERNAL_THREAD,
1766 2); 1789 2);
1790 fflush_allstd ();
1767 if (res) 1791 if (res)
1768 fprintf (stderr, 1792 fprintf (stderr,
1769 "FAILED: Upgrade with internal epoll, return code %d.\n", 1793 "FAILED: Upgrade with internal epoll, return code %d.\n",