mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-01 09:02:08 +00:00
[qfcc] Add a test for use/write dependencies
I ran into this with frikbot causing an infinite loop due to incorrectly linked objects.
This commit is contained in:
parent
44dd183d55
commit
4ad84b3786
2 changed files with 55 additions and 0 deletions
|
@ -30,6 +30,7 @@ test_progs_dat=\
|
||||||
tools/qfcc/test/gcd.dat \
|
tools/qfcc/test/gcd.dat \
|
||||||
tools/qfcc/test/infloop.dat \
|
tools/qfcc/test/infloop.dat \
|
||||||
tools/qfcc/test/ivar-struct-return.dat \
|
tools/qfcc/test/ivar-struct-return.dat \
|
||||||
|
tools/qfcc/test/link_order.dat \
|
||||||
tools/qfcc/test/methodparams.dat \
|
tools/qfcc/test/methodparams.dat \
|
||||||
tools/qfcc/test/modulo.dat \
|
tools/qfcc/test/modulo.dat \
|
||||||
tools/qfcc/test/nilparamret.dat \
|
tools/qfcc/test/nilparamret.dat \
|
||||||
|
@ -370,6 +371,16 @@ tools/qfcc/test/ivar-struct-return.run: $(qfcc_test_run_deps)
|
||||||
include $(ivar_struct_return_dep) # am--include-marker
|
include $(ivar_struct_return_dep) # am--include-marker
|
||||||
r_depfiles_remade += $(ivar_struct_return_dep)
|
r_depfiles_remade += $(ivar_struct_return_dep)
|
||||||
|
|
||||||
|
tools_qfcc_test_link_order_dat_SOURCES=tools/qfcc/test/link_order.r
|
||||||
|
link_order_obj=$(tools_qfcc_test_link_order_dat_SOURCES:.r=.o)
|
||||||
|
link_order_dep=$(call qcautodep,$(tools_qfcc_test_link_order_dat_SOURCES))
|
||||||
|
tools/qfcc/test/link_order.dat$(EXEEXT): $(link_order_obj) $(QFCC_DEP)
|
||||||
|
$(V_QFCCLD)$(QLINK) -o $@ $(link_order_obj)
|
||||||
|
tools/qfcc/test/link_order.run: $(qfcc_test_run_deps)
|
||||||
|
@$(top_srcdir)/tools/qfcc/test/build-run $@
|
||||||
|
include $(link_order_dep) # am--include-marker
|
||||||
|
r_depfiles_remade += $(link_order_dep)
|
||||||
|
|
||||||
tools_qfcc_test_methodparams_dat_SOURCES=tools/qfcc/test/methodparams.r
|
tools_qfcc_test_methodparams_dat_SOURCES=tools/qfcc/test/methodparams.r
|
||||||
methodparams_obj=$(tools_qfcc_test_methodparams_dat_SOURCES:.r=.o)
|
methodparams_obj=$(tools_qfcc_test_methodparams_dat_SOURCES:.r=.o)
|
||||||
methodparams_dep=$(call qcautodep,$(tools_qfcc_test_methodparams_dat_SOURCES))
|
methodparams_dep=$(call qcautodep,$(tools_qfcc_test_methodparams_dat_SOURCES))
|
||||||
|
|
44
tools/qfcc/test/link_order.r
Normal file
44
tools/qfcc/test/link_order.r
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#pragma bug die
|
||||||
|
#include "test-harness.h"
|
||||||
|
|
||||||
|
typedef struct link_s {
|
||||||
|
int something;
|
||||||
|
struct link_s *next;
|
||||||
|
} link_t;
|
||||||
|
|
||||||
|
link_t *
|
||||||
|
link_objs(link_t **array, int count)
|
||||||
|
{
|
||||||
|
link_t *obj = nil, *o;
|
||||||
|
while (count-- > 0) {
|
||||||
|
o = array[count];
|
||||||
|
o.next = obj;
|
||||||
|
obj = o;
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
link_t link_a;
|
||||||
|
link_t link_b;
|
||||||
|
link_t *links[2];
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
links[0] = &link_a;
|
||||||
|
links[1] = &link_b;
|
||||||
|
link_t *chain = link_objs (links, 2);
|
||||||
|
if (chain != &link_a) {
|
||||||
|
printf ("chain doesn't point to link_a\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (chain.next != &link_b) {
|
||||||
|
printf ("chain.next doesn't point to link_b\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (chain.next.next != nil) {
|
||||||
|
printf ("chain.next.next isn't nil\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue