diff options
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.29 2005/08/26 17:32:05 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.30 2005/08/26 17:36:32 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -737,7 +737,6 @@ static int loadlib (lua_State *L) { | |||
737 | static int closestate (lua_State *L) { | 737 | static int closestate (lua_State *L) { |
738 | lua_State *L1 = cast(lua_State *, cast(unsigned long, luaL_checknumber(L, 1))); | 738 | lua_State *L1 = cast(lua_State *, cast(unsigned long, luaL_checknumber(L, 1))); |
739 | lua_close(L1); | 739 | lua_close(L1); |
740 | lua_unlock(L); /* close cannot unlock that */ | ||
741 | return 0; | 740 | return 0; |
742 | } | 741 | } |
743 | 742 | ||
@@ -1121,39 +1120,26 @@ static const struct luaL_Reg tests_funcs[] = { | |||
1121 | }; | 1120 | }; |
1122 | 1121 | ||
1123 | 1122 | ||
1124 | static void fim (void) { | ||
1125 | if (!islocked) | ||
1126 | lua_close(lua_state); | ||
1127 | lua_assert(memcontrol.numblocks == 0); | ||
1128 | lua_assert(memcontrol.total == 0); | ||
1129 | } | ||
1130 | |||
1131 | |||
1132 | static int l_panic (lua_State *L) { | ||
1133 | UNUSED(L); | ||
1134 | fprintf(stderr, "unable to recover; exiting\n"); | ||
1135 | return 0; | ||
1136 | } | ||
1137 | |||
1138 | |||
1139 | int luaB_opentests (lua_State *L) { | 1123 | int luaB_opentests (lua_State *L) { |
1140 | void *ud; | 1124 | void *ud; |
1141 | lua_assert(lua_getallocf(L, &ud) == debug_realloc); | 1125 | lua_assert(lua_getallocf(L, &ud) == debug_realloc); |
1142 | lua_assert(ud == cast(void *, &memcontrol)); | 1126 | lua_assert(ud == cast(void *, &memcontrol)); |
1143 | lua_atpanic(L, l_panic); | ||
1144 | lua_state = L; /* keep first state to be opened */ | 1127 | lua_state = L; /* keep first state to be opened */ |
1145 | luaL_register(L, "T", tests_funcs); | 1128 | luaL_register(L, "T", tests_funcs); |
1146 | atexit(fim); | ||
1147 | return 0; | 1129 | return 0; |
1148 | } | 1130 | } |
1149 | 1131 | ||
1150 | 1132 | ||
1151 | #undef main | 1133 | #undef main |
1152 | int main (int argc, char *argv[]) { | 1134 | int main (int argc, char *argv[]) { |
1135 | int ret; | ||
1153 | char *limit = getenv("MEMLIMIT"); | 1136 | char *limit = getenv("MEMLIMIT"); |
1154 | if (limit) | 1137 | if (limit) |
1155 | memcontrol.memlimit = strtoul(limit, NULL, 10); | 1138 | memcontrol.memlimit = strtoul(limit, NULL, 10); |
1156 | return l_main(argc, argv); | 1139 | ret = l_main(argc, argv); |
1140 | lua_assert(memcontrol.numblocks == 0); | ||
1141 | lua_assert(memcontrol.total == 0); | ||
1142 | return ret; | ||
1157 | } | 1143 | } |
1158 | 1144 | ||
1159 | #endif | 1145 | #endif |