Skip to content

Commit 64ccef9

Browse files
committed
Attempt to fix linux test failure
1 parent 48ae8b8 commit 64ccef9

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

ast_tester/testfitschan.c

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
/* -----------------------------------------------------------------------
5050
* Static globals for the tabsource callback (replaces Fortran COMMON block)
5151
* -----------------------------------------------------------------------*/
52-
static AstKeyMap *g_tables = NULL;
52+
static AstFitsTable *g_table = NULL;
53+
static int *g_test_status = NULL;
5354

5455
/* -----------------------------------------------------------------------
5556
* stopit: record first error
@@ -68,45 +69,36 @@ static void stopit( int errnum, const char *text, int *status ) {
6869
* -----------------------------------------------------------------------*/
6970
static void tabsource( AstFitsChan *fc, const char *extnam, int extver,
7071
int extlevel, int *status ) {
71-
AstObject *table;
72+
*status = 0;
7273

7374
if( strcmp( extnam, "WCS-TAB" ) != 0 ) {
74-
stopit( 1035, "tabsource: unexpected extnam", status );
75+
stopit( 1035, "tabsource: unexpected extnam", g_test_status );
7576
return;
7677
}
7778

78-
if( !g_tables ) {
79-
stopit( 1036, "tabsource: g_tables is NULL", status );
79+
if( !g_table ) {
80+
stopit( 1036, "tabsource: g_table is NULL", g_test_status );
8081
return;
8182
}
8283

83-
if( !astMapGet0A( g_tables, extnam, &table ) ) {
84-
stopit( 1036, "tabsource: key not found", status );
85-
return;
86-
}
87-
88-
if( !astIsAFitsTable( table ) ) {
89-
stopit( 1037, "tabsource: not a FitsTable", status );
90-
astAnnul( table );
84+
if( !astIsAFitsTable( g_table ) ) {
85+
stopit( 1037, "tabsource: not a FitsTable", g_test_status );
9186
return;
9287
}
9388

9489
if( extver != 1 ) {
9590
printf( "EXTVER=%d\n", extver );
96-
stopit( 1065, "tabsource: wrong extver", status );
97-
astAnnul( table );
91+
stopit( 1065, "tabsource: wrong extver", g_test_status );
9892
return;
9993
}
10094

10195
if( extlevel != 1 ) {
102-
stopit( 1066, "tabsource: wrong extlevel", status );
103-
astAnnul( table );
96+
stopit( 1066, "tabsource: wrong extlevel", g_test_status );
10497
return;
10598
}
10699

107-
printf("tabsource called! g_tables size=%d\n", astMapSize(g_tables));
108-
astPutTables( fc, g_tables );
109-
astAnnul( table );
100+
astPutTable( fc, g_table, extnam );
101+
if( astOK ) *status = 1;
110102
}
111103

112104
/* -----------------------------------------------------------------------
@@ -650,14 +642,17 @@ static void checktab( int *status ) {
650642
if( ncard != astGetI( fc2, "Ncard" ) )
651643
stopit( 1034, " ", status );
652644

653-
/* Set g_tables so tabsource callback can use it */
654-
g_tables = tables;
645+
/* Set g_table so tabsource callback can use it */
646+
g_test_status = status;
647+
if( !astMapGet0A( tables, "WCS-TAB", (AstObject **) &g_table ) )
648+
stopit( 1034, "missing WCS-TAB table for callback", status );
655649
astTableSource( fc2, tabsource );
656650
astClear( fc2, "Card" );
657651
fs2 = (AstFrameSet *)astRead( fc2 );
658652
if( !fs2 ) stopit( 1035, " ", status );
659653
if( *status != 0 ) { printf("astRead at 678 failed! status=%d\n", *status); return; }
660-
g_tables = NULL;
654+
if( g_table ) g_table = astAnnul( g_table );
655+
g_test_status = NULL;
661656

662657
if( fs2 ) {
663658
AstFrame *fr1 = astGetFrame( fs, AST__CURRENT );

0 commit comments

Comments
 (0)