Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: session_manager_unittest.cc

Issue 3336018: Send SIGTERM and SIGABRT signals to a process group (Closed) Base URL: ssh://git@chromiumos-git//login_manager.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « session_manager_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "login_manager/session_manager_service.h" 5 #include "login_manager/session_manager_service.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <gtest/gtest.h> 8 #include <gtest/gtest.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 SimpleRunManager(); 341 SimpleRunManager();
342 } 342 }
343 343
344 static const pid_t kDummyPid = 4; 344 static const pid_t kDummyPid = 4;
345 TEST_F(SessionManagerTest, SessionNotStartedCleanupTest) { 345 TEST_F(SessionManagerTest, SessionNotStartedCleanupTest) {
346 MockChildJob* job = CreateTrivialMockJob(MAYBE_NEVER); 346 MockChildJob* job = CreateTrivialMockJob(MAYBE_NEVER);
347 manager_->test_api().set_child_pid(0, kDummyPid); 347 manager_->test_api().set_child_pid(0, kDummyPid);
348 348
349 int timeout = 3; 349 int timeout = 3;
350 EXPECT_CALL(*(utils_.get()), kill(kDummyPid, SIGKILL)) 350 EXPECT_CALL(*(utils_.get()), kill(-kDummyPid, SIGKILL))
351 .WillOnce(Return(0)); 351 .WillOnce(Return(0));
352 EXPECT_CALL(*(utils_.get()), ChildIsGone(kDummyPid, timeout)) 352 EXPECT_CALL(*(utils_.get()), ChildIsGone(kDummyPid, timeout))
353 .WillOnce(Return(true)); 353 .WillOnce(Return(true));
354 MockUtils(); 354 MockUtils();
355 355
356 manager_->test_api().CleanupChildren(timeout); 356 manager_->test_api().CleanupChildren(timeout);
357 } 357 }
358 358
359 TEST_F(SessionManagerTest, SessionNotStartedSlowKillCleanupTest) { 359 TEST_F(SessionManagerTest, SessionNotStartedSlowKillCleanupTest) {
360 MockChildJob* job = CreateTrivialMockJob(MAYBE_NEVER); 360 MockChildJob* job = CreateTrivialMockJob(MAYBE_NEVER);
361 manager_->test_api().set_child_pid(0, kDummyPid); 361 manager_->test_api().set_child_pid(0, kDummyPid);
362 362
363 int timeout = 3; 363 int timeout = 3;
364 EXPECT_CALL(*(utils_.get()), kill(kDummyPid, SIGKILL)) 364 EXPECT_CALL(*(utils_.get()), kill(-kDummyPid, SIGKILL))
365 .WillOnce(Return(0)); 365 .WillOnce(Return(0));
366 EXPECT_CALL(*(utils_.get()), ChildIsGone(kDummyPid, timeout)) 366 EXPECT_CALL(*(utils_.get()), ChildIsGone(kDummyPid, timeout))
367 .WillOnce(Return(false)); 367 .WillOnce(Return(false));
368 EXPECT_CALL(*(utils_.get()), kill(kDummyPid, SIGABRT)) 368 EXPECT_CALL(*(utils_.get()), kill(-kDummyPid, SIGABRT))
369 .WillOnce(Return(0)); 369 .WillOnce(Return(0));
370 MockUtils(); 370 MockUtils();
371 371
372 manager_->test_api().CleanupChildren(timeout); 372 manager_->test_api().CleanupChildren(timeout);
373 } 373 }
374 374
375 TEST_F(SessionManagerTest, SessionStartedCleanupTest) { 375 TEST_F(SessionManagerTest, SessionStartedCleanupTest) {
376 MockChildJob* job = CreateTrivialMockJob(MAYBE_NEVER); 376 MockChildJob* job = CreateTrivialMockJob(MAYBE_NEVER);
377 manager_->test_api().set_child_pid(0, kDummyPid); 377 manager_->test_api().set_child_pid(0, kDummyPid);
378 378
379 gboolean out; 379 gboolean out;
380 gchar email[] = "user@somewhere"; 380 gchar email[] = "user@somewhere";
381 gchar nothing[] = ""; 381 gchar nothing[] = "";
382 int timeout = 3; 382 int timeout = 3;
383 EXPECT_CALL(*(utils_.get()), kill(kDummyPid, SIGTERM)) 383 EXPECT_CALL(*(utils_.get()), kill(-kDummyPid, SIGTERM))
384 .WillOnce(Return(0)); 384 .WillOnce(Return(0));
385 EXPECT_CALL(*(utils_.get()), ChildIsGone(kDummyPid, timeout)) 385 EXPECT_CALL(*(utils_.get()), ChildIsGone(kDummyPid, timeout))
386 .WillOnce(Return(true)); 386 .WillOnce(Return(true));
387 MockUtils(); 387 MockUtils();
388 388
389 std::string email_string(email); 389 std::string email_string(email);
390 EXPECT_CALL(*job, StartSession(email_string)) 390 EXPECT_CALL(*job, StartSession(email_string))
391 .Times(1); 391 .Times(1);
392 392
393 manager_->StartSession(email, nothing, &out, NULL); 393 manager_->StartSession(email, nothing, &out, NULL);
394 manager_->test_api().CleanupChildren(timeout); 394 manager_->test_api().CleanupChildren(timeout);
395 } 395 }
396 396
397 TEST_F(SessionManagerTest, SessionStartedSlowKillCleanupTest) { 397 TEST_F(SessionManagerTest, SessionStartedSlowKillCleanupTest) {
398 MockChildJob* job = CreateTrivialMockJob(MAYBE_NEVER); 398 MockChildJob* job = CreateTrivialMockJob(MAYBE_NEVER);
399 SessionManagerService::TestApi test_api = manager_->test_api(); 399 SessionManagerService::TestApi test_api = manager_->test_api();
400 test_api.set_child_pid(0, kDummyPid); 400 test_api.set_child_pid(0, kDummyPid);
401 401
402 int timeout = 3; 402 int timeout = 3;
403 EXPECT_CALL(*(utils_.get()), kill(kDummyPid, SIGTERM)) 403 EXPECT_CALL(*(utils_.get()), kill(-kDummyPid, SIGTERM))
404 .WillOnce(Return(0)); 404 .WillOnce(Return(0));
405 EXPECT_CALL(*(utils_.get()), ChildIsGone(kDummyPid, timeout)) 405 EXPECT_CALL(*(utils_.get()), ChildIsGone(kDummyPid, timeout))
406 .WillOnce(Return(false)); 406 .WillOnce(Return(false));
407 EXPECT_CALL(*(utils_.get()), kill(kDummyPid, SIGABRT)) 407 EXPECT_CALL(*(utils_.get()), kill(-kDummyPid, SIGABRT))
408 .WillOnce(Return(0)); 408 .WillOnce(Return(0));
409 MockUtils(); 409 MockUtils();
410 410
411 gboolean out; 411 gboolean out;
412 gchar email[] = "user@somewhere"; 412 gchar email[] = "user@somewhere";
413 gchar nothing[] = ""; 413 gchar nothing[] = "";
414 414
415 std::string email_string(email); 415 std::string email_string(email);
416 EXPECT_CALL(*job, StartSession(email_string)) 416 EXPECT_CALL(*job, StartSession(email_string))
417 .Times(1); 417 .Times(1);
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 } 1043 }
1044 1044
1045 TEST(SessionManagerTestStatic, GetArgLists3_InitialDashes) { 1045 TEST(SessionManagerTestStatic, GetArgLists3_InitialDashes) {
1046 const char* c_args[] = {"--", "a", "b", "c", NULL}; 1046 const char* c_args[] = {"--", "a", "b", "c", NULL};
1047 std::vector<std::vector<std::string> > arg_lists = GetArgs(c_args); 1047 std::vector<std::vector<std::string> > arg_lists = GetArgs(c_args);
1048 EXPECT_EQ(1, arg_lists.size()); 1048 EXPECT_EQ(1, arg_lists.size());
1049 EXPECT_EQ(3, arg_lists[0].size()); 1049 EXPECT_EQ(3, arg_lists[0].size());
1050 } 1050 }
1051 1051
1052 } // namespace login_manager 1052 } // namespace login_manager
OLDNEW
« no previous file with comments | « session_manager_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698