Skip to content

Commit 2c95109

Browse files
authored
Remove trivial testing of stack usage (#21001)
All these tests do is allocate (or try to, at least) many things on the stack, either using structs passed by value or printf. But this is simply a clang codegen issue now, so we can leave it to there. Also, some of these tests were not even valid: they almost tested whether we used an unexpectedly large amount of stack, but they didn't do even that as the removed comments about a larger stack size show (i.e. we enlarged the stack size to work around a CI issue, but that meant we aren't testing that we work even with a small stack size). Regardless we have good testing for our stack checks, which are the proper solution to this issue (that is, we don't break weirdly if the user set the stack as too small), and so we don't need to duplicate any clang testing.
1 parent 546353b commit 2c95109

File tree

7 files changed

+0
-194
lines changed

7 files changed

+0
-194
lines changed

test/core/test_stack_byval.cpp

Lines changed: 0 additions & 30 deletions
This file was deleted.

test/core/test_stack_byval.out

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/core/test_stack_varargs.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

test/core/test_stack_varargs.out

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/core/test_stack_void.c

Lines changed: 0 additions & 41 deletions
This file was deleted.

test/core/test_stack_void.out

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/test_core.py

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,103 +1717,6 @@ def test_remove(self):
17171717
def test_alloca_stack(self):
17181718
self.do_core_test('test_alloca_stack.c')
17191719

1720-
def test_stack_byval(self):
1721-
self.do_core_test('test_stack_byval.cpp')
1722-
1723-
def test_stack_varargs(self):
1724-
# in node.js we allocate argv[0] on the stack, which means the length
1725-
# of the program directory influences how much stack we need, and so
1726-
# long random temp dir names can lead to random failures. The stack
1727-
# size was increased here to avoid that.
1728-
self.set_setting('INLINING_LIMIT')
1729-
self.set_setting('STACK_SIZE', 8 * 1024)
1730-
1731-
self.do_core_test('test_stack_varargs.c')
1732-
1733-
def test_stack_varargs2(self):
1734-
# in node.js we allocate argv[0] on the stack, which means the length
1735-
# of the program directory influences how much stack we need, and so
1736-
# long random temp dir names can lead to random failures. The stack
1737-
# size was increased here to avoid that.
1738-
self.set_setting('STACK_SIZE', 8 * 1024)
1739-
src = r'''
1740-
#include <stdio.h>
1741-
#include <stdlib.h>
1742-
1743-
void func(int i) {
1744-
}
1745-
int main() {
1746-
for (int i = 0; i < 7000; i++) {
1747-
printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
1748-
i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i);
1749-
}
1750-
printf("ok!\n");
1751-
return 0;
1752-
}
1753-
'''
1754-
self.do_run(src, 'ok!')
1755-
1756-
print('with return')
1757-
1758-
src = r'''
1759-
#include <stdio.h>
1760-
#include <stdlib.h>
1761-
1762-
int main() {
1763-
for (int i = 0; i < 7000; i++) {
1764-
int j = printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
1765-
i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i);
1766-
printf(" (%d)\n", j);
1767-
}
1768-
printf("ok!\n");
1769-
return 0;
1770-
}
1771-
'''
1772-
self.do_run(src, 'ok!')
1773-
1774-
print('with definitely no return')
1775-
1776-
src = r'''
1777-
#include <stdio.h>
1778-
#include <stdlib.h>
1779-
#include <stdarg.h>
1780-
1781-
void vary(const char *s, ...)
1782-
{
1783-
va_list v;
1784-
va_start(v, s);
1785-
char d[20];
1786-
vsnprintf(d, 20, s, v);
1787-
puts(d);
1788-
1789-
// Try it with copying
1790-
va_list tempva;
1791-
va_copy(tempva, v);
1792-
vsnprintf(d, 20, s, tempva);
1793-
puts(d);
1794-
1795-
va_end(v);
1796-
}
1797-
1798-
int main() {
1799-
for (int i = 0; i < 7000; i++) {
1800-
int j = printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
1801-
i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i);
1802-
printf(" (%d)\n", j);
1803-
vary("*cheez: %d+%d*", 99, 24);
1804-
vary("*albeit*");
1805-
}
1806-
printf("ok!\n");
1807-
return 0;
1808-
}
1809-
'''
1810-
self.do_run(src, 'ok!')
1811-
1812-
def test_stack_void(self):
1813-
self.emcc_args.append('-Wno-format-extra-args')
1814-
self.set_setting('INLINING_LIMIT')
1815-
self.do_core_test('test_stack_void.c')
1816-
18171720
def test_life(self):
18181721
self.do_run_in_out_file_test('life.c', args=['2'])
18191722

0 commit comments

Comments
 (0)