[libc-commits] [libc] [libc] Refactor getopt to use standard reset and internal test hook (PR #197644)
Alexey Samsonov via libc-commits
libc-commits at lists.llvm.org
Thu May 14 11:58:30 PDT 2026
================
@@ -68,12 +55,14 @@ struct LlvmLibcGetoptTest : public LIBC_NAMESPACE::testing::Test {
void SetUp() override {
ASSERT_TRUE(!!(errstream = memopen(&pos)));
set_state(errstream);
- ASSERT_EQ(test_globals::optind, 1);
+ LIBC_NAMESPACE::impl::optind = 0;
+ LIBC_NAMESPACE::getopt(0, nullptr, "");
}
void TearDown() override {
- test_globals::optind = 1;
- test_globals::opterr = 1;
+ LIBC_NAMESPACE::impl::optind = 0;
----------------
vonosmas wrote:
Conversely, why do you need this here? I think we shouldn't do a whole lot of work at TearDown, assuming SetUp would clean the state for us properly.
https://github.com/llvm/llvm-project/pull/197644
More information about the libc-commits
mailing list