merge job rusage and pending reason support
This commit is contained in:
parent
30824ae5ea
commit
cb0c7fe9e7
82 changed files with 4280 additions and 2561 deletions
168
src/lib/testsuite/test_preason.c
Normal file
168
src/lib/testsuite/test_preason.c
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "preason.h"
|
||||
#include "unity.h"
|
||||
|
||||
static void test_main_reason()
|
||||
{
|
||||
xce_job_preason_t reason;
|
||||
|
||||
memset(&reason, 0x0, sizeof(reason));
|
||||
|
||||
add_job_preason(&reason, 1, NULL, NULL);
|
||||
TEST_ASSERT_TRUE(reason.main_reason == 1);
|
||||
TEST_ASSERT_TRUE((reason.nhost_reasons == 0)
|
||||
&& (reason.host_based_reasons == NULL));
|
||||
TEST_ASSERT_TRUE((reason.nres_reasons == 0)
|
||||
&& (reason.res_based_reasons == NULL));
|
||||
}
|
||||
|
||||
static void test_add_host_reason(void)
|
||||
{
|
||||
xce_job_preason_t reason;
|
||||
|
||||
memset(&reason, 0x0, sizeof(reason));
|
||||
|
||||
add_job_preason(&reason, 1, "h1", NULL);
|
||||
TEST_ASSERT_TRUE(reason.main_reason == 0);
|
||||
TEST_ASSERT_TRUE((reason.nhost_reasons == 1)
|
||||
&& (reason.host_based_reasons != NULL)
|
||||
&& (reason.host_based_reasons[0] != NULL));
|
||||
TEST_ASSERT_TRUE(
|
||||
(reason.host_based_reasons[0]->reason == 1)
|
||||
&& (strcmp(reason.host_based_reasons[0]->host, "h1") == 0));
|
||||
TEST_ASSERT_TRUE((reason.nres_reasons == 0)
|
||||
&& (reason.res_based_reasons == NULL));
|
||||
erase_job_preason(&reason);
|
||||
}
|
||||
|
||||
static void test_add_res_reason(void)
|
||||
{
|
||||
xce_job_preason_t reason;
|
||||
|
||||
memset(&reason, 0x0, sizeof(reason));
|
||||
|
||||
add_job_preason(&reason, 1, "h1", "res1");
|
||||
TEST_ASSERT_TRUE(reason.main_reason == 0);
|
||||
TEST_ASSERT_TRUE((reason.nres_reasons == 1)
|
||||
&& (reason.res_based_reasons != NULL)
|
||||
&& (reason.res_based_reasons[0] != NULL));
|
||||
TEST_ASSERT_TRUE(
|
||||
(reason.res_based_reasons[0]->reason == 1)
|
||||
&& (strcmp(reason.res_based_reasons[0]->host, "h1") == 0)
|
||||
&& (strcmp(reason.res_based_reasons[0]->resource, "res1") == 0));
|
||||
TEST_ASSERT_TRUE((reason.nhost_reasons == 0)
|
||||
&& (reason.host_based_reasons == NULL));
|
||||
erase_job_preason(&reason);
|
||||
}
|
||||
|
||||
static void test_add_res_host_reason(void)
|
||||
{
|
||||
xce_job_preason_t reason;
|
||||
|
||||
memset(&reason, 0x0, sizeof(reason));
|
||||
|
||||
add_job_preason(&reason, 1, "h1", "res1");
|
||||
add_job_preason(&reason, 2, "h1", NULL);
|
||||
|
||||
TEST_ASSERT_TRUE(reason.main_reason == 0);
|
||||
TEST_ASSERT_TRUE((reason.nres_reasons == 1)
|
||||
&& (reason.res_based_reasons != NULL)
|
||||
&& (reason.res_based_reasons[0] != NULL));
|
||||
TEST_ASSERT_TRUE(
|
||||
(reason.res_based_reasons[0]->reason == 1)
|
||||
&& (strcmp(reason.res_based_reasons[0]->host, "h1") == 0)
|
||||
&& (strcmp(reason.res_based_reasons[0]->resource, "res1") == 0));
|
||||
TEST_ASSERT_TRUE((reason.nhost_reasons == 1)
|
||||
&& (reason.host_based_reasons != NULL)
|
||||
&& (reason.host_based_reasons[0] != NULL));
|
||||
TEST_ASSERT_TRUE(
|
||||
(reason.host_based_reasons[0]->reason == 2)
|
||||
&& (strcmp(reason.host_based_reasons[0]->host, "h1") == 0));
|
||||
erase_job_preason(&reason);
|
||||
}
|
||||
|
||||
static void test_add_main_reset_other(void)
|
||||
{
|
||||
xce_job_preason_t reason;
|
||||
|
||||
memset(&reason, 0x0, sizeof(reason));
|
||||
|
||||
add_job_preason(&reason, 1, "h1", "res1");
|
||||
add_job_preason(&reason, 2, "h1", NULL);
|
||||
add_job_preason(&reason, 3, NULL, NULL);
|
||||
|
||||
TEST_ASSERT_TRUE(reason.main_reason == 3);
|
||||
TEST_ASSERT_TRUE((reason.nres_reasons == 0)
|
||||
&& (reason.res_based_reasons == NULL));
|
||||
TEST_ASSERT_TRUE((reason.nhost_reasons == 0)
|
||||
&& (reason.host_based_reasons == NULL));
|
||||
erase_job_preason(&reason);
|
||||
}
|
||||
|
||||
static void test_add_more_host_reason(void)
|
||||
{
|
||||
xce_job_preason_t reason;
|
||||
|
||||
memset(&reason, 0x0, sizeof(reason));
|
||||
|
||||
add_job_preason(&reason, 1, "h1", NULL);
|
||||
add_job_preason(&reason, 2, "h2", NULL);
|
||||
|
||||
TEST_ASSERT_TRUE(reason.main_reason == 0);
|
||||
TEST_ASSERT_TRUE((reason.nhost_reasons == 2)
|
||||
&& (reason.host_based_reasons != NULL)
|
||||
&& (reason.host_based_reasons[0] != NULL)
|
||||
&& (reason.host_based_reasons[1] != NULL));
|
||||
TEST_ASSERT_TRUE(
|
||||
(reason.host_based_reasons[0]->reason == 1)
|
||||
&& (strcmp(reason.host_based_reasons[0]->host, "h1") == 0)
|
||||
&& (reason.host_based_reasons[1]->reason == 2)
|
||||
&& (strcmp(reason.host_based_reasons[1]->host, "h2") == 0));
|
||||
TEST_ASSERT_TRUE((reason.nres_reasons == 0)
|
||||
&& (reason.res_based_reasons == NULL));
|
||||
erase_job_preason(&reason);
|
||||
}
|
||||
|
||||
static void test_add_more_res_reason(void)
|
||||
{
|
||||
xce_job_preason_t reason;
|
||||
|
||||
memset(&reason, 0x0, sizeof(reason));
|
||||
|
||||
add_job_preason(&reason, 1, "h1", "res1");
|
||||
add_job_preason(&reason, 2, "h2", "res2");
|
||||
|
||||
TEST_ASSERT_TRUE(reason.main_reason == 0);
|
||||
TEST_ASSERT_TRUE((reason.nres_reasons == 2)
|
||||
&& (reason.res_based_reasons != NULL)
|
||||
&& (reason.res_based_reasons[0] != NULL)
|
||||
&& (reason.res_based_reasons[1] != NULL));
|
||||
TEST_ASSERT_TRUE(
|
||||
(reason.res_based_reasons[0]->reason == 1)
|
||||
&& (strcmp(reason.res_based_reasons[0]->host, "h1") == 0)
|
||||
&& (strcmp(reason.res_based_reasons[0]->resource, "res1") == 0));
|
||||
TEST_ASSERT_TRUE(
|
||||
(reason.res_based_reasons[1]->reason == 2)
|
||||
&& (strcmp(reason.res_based_reasons[1]->host, "h2") == 0)
|
||||
&& (strcmp(reason.res_based_reasons[1]->resource, "res2") == 0));
|
||||
|
||||
TEST_ASSERT_TRUE((reason.nhost_reasons == 0)
|
||||
&& (reason.host_based_reasons == NULL));
|
||||
erase_job_preason(&reason);
|
||||
}
|
||||
|
||||
void test_preason(void)
|
||||
{
|
||||
printf("\n>> preason test\n\n");
|
||||
|
||||
RUN_TEST(test_main_reason);
|
||||
RUN_TEST(test_add_host_reason);
|
||||
RUN_TEST(test_add_res_reason);
|
||||
RUN_TEST(test_add_res_host_reason);
|
||||
RUN_TEST(test_add_main_reset_other);
|
||||
RUN_TEST(test_add_more_host_reason);
|
||||
RUN_TEST(test_add_more_res_reason);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue