Skip to content

Commit

Permalink
Fix comparisons between pointers and integers in test
Browse files Browse the repository at this point in the history
Some compilers like Apple clang-15 reject constructs like this outright,
so replace them with checks for "truthiness".
  • Loading branch information
bbannier committed Sep 2, 2024
1 parent 99f14e5 commit f4acaf4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cc/src/tokenpool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ TEST_F(TokenPoolTest, SuccessfulOldSetup) {
// GNUmake <= 4.1
CreatePool(AUTH_FORMAT("--jobserver-fds"));

EXPECT_NE(NULL, tokens_);
EXPECT_TRUE(tokens_);
EXPECT_EQ(kLoadAverageDefault, load_avg_);
}

TEST_F(TokenPoolTest, SuccessfulNewSetup) {
// GNUmake => 4.2
CreateDefaultPool();

EXPECT_NE(NULL, tokens_);
EXPECT_TRUE(tokens_);
EXPECT_EQ(kLoadAverageDefault, load_avg_);
}

Expand All @@ -194,7 +194,7 @@ TEST_F(TokenPoolTest, IgnoreWithJN) {
TEST_F(TokenPoolTest, HonorLN) {
CreatePool(AUTH_FORMAT("-l9 --jobserver-auth"));

EXPECT_NE(NULL, tokens_);
EXPECT_TRUE(tokens_);
EXPECT_EQ(9.0, load_avg_);
}

Expand All @@ -203,14 +203,14 @@ TEST_F(TokenPoolTest, SemaphoreNotFound) {
semaphore_name_ = SEMAPHORE_NAME "_foobar";
CreateDefaultPool();

EXPECT_EQ(NULL, tokens_);
EXPECT_TRUE(tokens_);
EXPECT_EQ(kLoadAverageDefault, load_avg_);
}

TEST_F(TokenPoolTest, TokenIsAvailable) {
CreateDefaultPool();

ASSERT_NE(NULL, tokens_);
ASSERT_TRUE(tokens_);
EXPECT_EQ(kLoadAverageDefault, load_avg_);

EXPECT_TRUE(tokens_->TokenIsAvailable((ULONG_PTR)tokens_));
Expand All @@ -219,7 +219,7 @@ TEST_F(TokenPoolTest, TokenIsAvailable) {
TEST_F(TokenPoolTest, MonitorFD) {
CreateDefaultPool();

ASSERT_NE(NULL, tokens_);
ASSERT_TRUE(tokens_);
EXPECT_EQ(kLoadAverageDefault, load_avg_);

EXPECT_EQ(fds_[0], tokens_->GetMonitorFd());
Expand All @@ -229,7 +229,7 @@ TEST_F(TokenPoolTest, MonitorFD) {
TEST_F(TokenPoolTest, ImplicitToken) {
CreateDefaultPool();

ASSERT_NE(NULL, tokens_);
ASSERT_TRUE(tokens_);
EXPECT_EQ(kLoadAverageDefault, load_avg_);

EXPECT_TRUE(tokens_->Acquire());
Expand All @@ -242,7 +242,7 @@ TEST_F(TokenPoolTest, ImplicitToken) {
TEST_F(TokenPoolTest, TwoTokens) {
CreateDefaultPool();

ASSERT_NE(NULL, tokens_);
ASSERT_TRUE(tokens_);
EXPECT_EQ(kLoadAverageDefault, load_avg_);

// implicit token
Expand Down Expand Up @@ -286,7 +286,7 @@ TEST_F(TokenPoolTest, TwoTokens) {
TEST_F(TokenPoolTest, Clear) {
CreateDefaultPool();

ASSERT_NE(NULL, tokens_);
ASSERT_TRUE(tokens_);
EXPECT_EQ(kLoadAverageDefault, load_avg_);

// implicit token
Expand Down Expand Up @@ -328,17 +328,17 @@ TEST_F(TokenPoolTest, Clear) {
TEST_F(TokenPoolTest, NoPoolForSerialBuild) {
CreateMaster(1);

EXPECT_EQ(NULL, tokens_);
EXPECT_FALSE(tokens_);
}

TEST_F(TokenPoolTest, MasterNoLoadAvg) {
// kLoadAverageDefault <= 0.0f -> no load averaging
CreateMaster(2);

ASSERT_NE(NULL, tokens_);
ASSERT_TRUE(tokens_);

const char *env = ENVIRONMENT_GET();
ASSERT_NE(NULL, env);
ASSERT_TRUE(env);

EXPECT_EQ(env, strstr(env, "--jobserver-auth="));
EXPECT_EQ(NULL, strstr(env, " -l"));
Expand All @@ -350,13 +350,13 @@ TEST_F(TokenPoolTest, MasterWithLoadAvg) {
load_avg_ = 3.1415f;
CreateMaster(3);

ASSERT_NE(NULL, tokens_);
ASSERT_TRUE(tokens_);

const char *env = ENVIRONMENT_GET();
ASSERT_NE(NULL, env);
ASSERT_TRUE(env);

EXPECT_EQ(env, strstr(env, "--jobserver-auth="));
EXPECT_NE(NULL, strstr(env, " -l3.1415"));
EXPECT_TRUE(strstr(env, " -l3.1415"));

CheckTokens(env, 3);
}

0 comments on commit f4acaf4

Please sign in to comment.