424
test_job_config_path (void)
428
TEST_FUNCTION ("control_job_config_path");
430
/* Check that the path for an ordinary name can be returned as
433
TEST_FEATURE ("with ordinary name");
435
path = control_job_config_path (NULL, "foo");
437
if (test_alloc_failed) {
438
TEST_EQ_P (path, NULL);
443
TEST_EQ_STR (path, "/com/ubuntu/Upstart/jobs/foo");
449
/* Check that the path of a job name that requires escaping is
450
* escaped using the _xx notation.
452
TEST_FEATURE ("with name that requires escaping");
454
path = control_job_config_path (NULL, "foo/bar.baz");
456
if (test_alloc_failed) {
457
TEST_EQ_P (path, NULL);
462
TEST_EQ_STR (path, "/com/ubuntu/Upstart/jobs/foo_2fbar_2ebaz");
468
/* Check that the path of a job name that contains an underscore has
469
* that escaped to ensure uniqueness with other escaped paths.
471
TEST_FEATURE ("with underscore in name");
473
path = control_job_config_path (NULL, "foo_bar");
475
if (test_alloc_failed) {
476
TEST_EQ_P (path, NULL);
481
TEST_EQ_STR (path, "/com/ubuntu/Upstart/jobs/foo_5fbar");
492
TEST_FUNCTION ("control_job_path");
494
/* Check that the path for ordinary names can be returned as we'd
497
TEST_FEATURE ("with ordinary names");
499
path = control_job_path (NULL, "foo", "bar");
501
if (test_alloc_failed) {
502
TEST_EQ_P (path, NULL);
507
TEST_EQ_STR (path, "/com/ubuntu/Upstart/jobs/foo/bar");
513
/* Check that the job instance name may be NULL and will be
514
* substituted for the name "active" (which is safe since these jobs
515
* will never have more than one instance).
517
TEST_FEATURE ("with instance-less job");
519
path = control_job_path (NULL, "foo", NULL);
521
if (test_alloc_failed) {
522
TEST_EQ_P (path, NULL);
527
TEST_EQ_STR (path, "/com/ubuntu/Upstart/jobs/foo/active");
533
/* Check that the path of a job config name that requires escaping is
534
* escaped using the _xx notation.
536
TEST_FEATURE ("with config name that requires escaping");
538
path = control_job_path (NULL, "foo/bar.baz", "frodo");
540
if (test_alloc_failed) {
541
TEST_EQ_P (path, NULL);
547
"/com/ubuntu/Upstart/jobs/foo_2fbar_2ebaz/frodo");
553
/* Check that the path of a job instance name that requires escaping
554
* is escaped using the _xx notation.
556
TEST_FEATURE ("with instance name that requires escaping");
558
path = control_job_path (NULL, "foo", "frodo+baggins");
560
if (test_alloc_failed) {
561
TEST_EQ_P (path, NULL);
567
"/com/ubuntu/Upstart/jobs/foo/frodo_2bbaggins");
573
/* Check that the paths of a job config and instance name that
574
* require escaping are using the _xx notation.
576
TEST_FEATURE ("with both names requiring escaping");
578
path = control_job_path (NULL, "foo/bar.baz", "frodo+baggins");
580
if (test_alloc_failed) {
581
TEST_EQ_P (path, NULL);
587
"/com/ubuntu/Upstart/jobs/foo_2fbar_2ebaz/"
594
/* Check that the path of a job config name that contains an
595
* underscore has that escaped to ensure uniqueness with other
598
TEST_FEATURE ("with underscore in config name");
600
path = control_job_path (NULL, "foo_bar", "frodo");
602
if (test_alloc_failed) {
603
TEST_EQ_P (path, NULL);
608
TEST_EQ_STR (path, "/com/ubuntu/Upstart/jobs/foo_5fbar/frodo");
614
/* Check that the path of a job instance name that contains an
615
* underscore has that escaped to ensure uniqueness with other
618
TEST_FEATURE ("with underscore in instance name");
620
path = control_job_path (NULL, "foo", "frodo_baggins");
622
if (test_alloc_failed) {
623
TEST_EQ_P (path, NULL);
629
"/com/ubuntu/Upstart/jobs/foo/frodo_5fbaggins");
635
/* Check that the path of job config and instance names that contain
636
* underscores have that escaped to ensure uniqueness with other
639
TEST_FEATURE ("with underscore in both names");
641
path = control_job_path (NULL, "foo_bar", "frodo_baggins");
643
if (test_alloc_failed) {
644
TEST_EQ_P (path, NULL);
650
"/com/ubuntu/Upstart/jobs/foo_5fbar/"