static int _tc_tdm_pipe_read_msg(int fd);
static bool _tc_tdm_pipe_write_msg(int fd, int reply_fd, int msg);
static pid_t _tc_tdm_client_server_fork(int *pipe_to_parent, int *pipe_to_child);
+static void _tc_tdm_client_server_kill(int *pipe_parent, int *pipe_child, pid_t server_pid);
class TDMClient : public TDMEnv
{
void TDMClient::ServerKill(void)
{
- if (pipe_child[0] >= 0)
- close(pipe_child[0]);
- if (pipe_child[1] >= 0) {
- if (server_pid > 0) {
- bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
- if (ret) {
- if (waitpid(server_pid, NULL, 0) == server_pid)
- TDM_INFO("*** server terminated ***");
- else
- TDM_ERR("*** failed to terminate server ***");
- } else {
- if (kill(server_pid, 9) < 0)
- TDM_ERR("*** failed to kill server ***");
- }
- }
- close(pipe_child[1]);
- }
-
- if (pipe_parent[0] >= 0)
- close(pipe_parent[0]);
- if (pipe_parent[1] >= 0)
- close(pipe_parent[1]);
+ _tc_tdm_client_server_kill(pipe_parent, pipe_child, server_pid);
server_pid = -1;
pipe_parent[0] = pipe_parent[1] = -1;
}
+static void
+_tc_tdm_client_server_kill(int *pipe_parent, int *pipe_child, pid_t server_pid)
+{
+ if (pipe_child[0] >= 0)
+ close(pipe_child[0]);
+ if (pipe_child[1] >= 0) {
+ if (server_pid > 0) {
+ bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
+ if (ret) {
+ if (waitpid(server_pid, NULL, 0) == server_pid)
+ TDM_INFO("*** server terminated ***");
+ else
+ TDM_ERR("*** failed to terminate server ***");
+ } else {
+ if (kill(server_pid, 9) < 0)
+ TDM_ERR("*** failed to kill server ***");
+ }
+ }
+ close(pipe_child[1]);
+ }
+
+ if (pipe_parent[0] >= 0)
+ close(pipe_parent[0]);
+ if (pipe_parent[1] >= 0)
+ close(pipe_parent[1]);
+}
+
static void _tc_tdm_client_sig_handler(int sig)
{
TDM_UT_ERR("got signal: %d", sig);
EXPECT_EQ(tdm_client_vblank_wait(vblank, 0, _tc_tdm_client_vblank_cb2, NULL), TDM_ERROR_INVALID_PARAMETER);
}
+static void
+_tc_tdm_client_print_vblank_info(double start, double end, int vrefresh_interval, int t)
+{
+ /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
+ //EXPECT_GT((end - start), (vrefresh_interval * (t - 1)));
+ double a = end - start;
+ double b = vrefresh_interval * (t - 1);
+ if (a > b)
+ std::cout << "\033[0;35m"
+ << "==> Error: "
+ << "\033[0;33m"
+ << "Expected: ((end - start) > (vrefresh_interval * (t - 1))), "
+ << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl;
+
+ //EXPECT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
+ a = end - start;
+ b = vrefresh_interval * t + vrefresh_interval;
+ if (a < b)
+ std::cout << "\033[0;35m"
+ << "==> Error: "
+ << "\033[0;33m"
+ << "Expected: ((end - start) < (vrefresh_interval * t + vrefresh_interval)), "
+ << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl;
+}
+
TEST_P(TDMClient, ClientVblankWaitInterval)
{
bool done;
EXPECT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
end = tdm_helper_get_time();
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- //EXPECT_GT((end - start), (vrefresh_interval * (t - 1)));
- double a = end - start;
- double b = vrefresh_interval * (t - 1);
- if (a > b)
- std::cout << "\033[0;35m"
- << "==> Error: "
- << "\033[0;33m"
- << "Expected: ((end - start) > (vrefresh_interval * (t - 1))), "
- << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl;
-
- //EXPECT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
- a = end - start;
- b = vrefresh_interval * t + vrefresh_interval;
- if (a < b)
- std::cout << "\033[0;35m"
- << "==> Error: "
- << "\033[0;33m"
- << "Expected: ((end - start) < (vrefresh_interval * t + vrefresh_interval)), "
- << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl;
+ _tc_tdm_client_print_vblank_info(start, end, vrefresh_interval, t);
}
}
EXPECT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE);
end = tdm_helper_get_time();
- /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */
- //EXPECT_GT((end - start), (vrefresh_interval * (t - 1)));
- double a = end - start;
- double b = vrefresh_interval * (t - 1);
- if (a > b)
- std::cout << "\033[0;35m"
- << "==> Error: "
- << "\033[0;33m"
- << "Expected: ((end - start) > (vrefresh_interval * (t - 1))), "
- << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl;
-
- //EXPECT_LT((end - start), (vrefresh_interval * t + vrefresh_interval));
- a = end - start;
- b = vrefresh_interval * t + vrefresh_interval;
- if (a < b)
- std::cout << "\033[0;35m"
- << "==> Error: "
- << "\033[0;33m"
- << "Expected: ((end - start) < (vrefresh_interval * t + vrefresh_interval)), "
- << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl;
+ _tc_tdm_client_print_vblank_info(start, end, vrefresh_interval, t);
}
}
static void SetUpTestCase();
static void TearDownTestCase();
static bool PrepareVOutput(void);
+ static bool ConnectVOutput(unsigned int mmWidth, unsigned int mmHeight, int mode_count);
protected:
static tdm_client *client;
void TDMVirtualOutput::ServerKill(void)
{
- if (pipe_child[0] >= 0)
- close(pipe_child[0]);
- if (pipe_child[1] >= 0) {
- if (server_pid > 0) {
- bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER);
- if (ret) {
- if (waitpid(server_pid, NULL, 0) == server_pid)
- TDM_INFO("*** server terminated ***");
- else
- TDM_ERR("*** failed to terminate server ***");
- } else {
- if (kill(server_pid, 9) < 0)
- TDM_ERR("*** failed to kill server ***");
- }
- }
- close(pipe_child[1]);
- }
-
- if (pipe_parent[0] >= 0)
- close(pipe_parent[0]);
- if (pipe_parent[1] >= 0)
- close(pipe_parent[1]);
+ _tc_tdm_client_server_kill(pipe_parent, pipe_child, server_pid);
server_pid = -1;
pipe_parent[0] = pipe_parent[1] = -1;
}
}
+bool TDMVirtualOutput::ConnectVOutput(unsigned int mmWidth, unsigned int mmHeight, int mode_count)
+{
+ tdm_client_output_mode modes[mode_count];
+ tdm_error ret;
+
+ ret = tdm_client_voutput_set_physical_size(voutput, mmWidth, mmHeight);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ _tc_tdm_client_virutual_make_available_mode(modes, mode_count);
+ ret = tdm_client_voutput_set_available_modes(voutput, modes, mode_count);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ ret = tdm_client_voutput_connect(voutput);
+ TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE);
+
+ return true;
+}
+
TEST_F(TDMVirtualOutput, SetAvailableModes)
{
tdm_error ret;
tdm_error ret;
tdm_client_output *output;
unsigned int mmWidth = 300, mmHeight = 150;
- tdm_client_output_mode modes[this->MODE_COUNT];
- int count = this->MODE_COUNT;
int virtual_conf;
bool done = false;
bool done2 = false;
ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb2, &done2);
EXPECT_EQ(ret, TDM_ERROR_NONE);
- ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
-
- _tc_tdm_client_virutual_make_available_mode(modes, count);
- ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
-
- ret = tdm_client_voutput_connect(this->voutput);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
+ EXPECT_EQ(ConnectVOutput(mmWidth, mmHeight, this->MODE_COUNT), true);
while (!done)
EXPECT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
tdm_error ret;
tdm_client_output *output;
unsigned int mmWidth = 300, mmHeight = 150;
- tdm_client_output_mode modes[this->MODE_COUNT];
int count = this->MODE_COUNT;
int virtual_conf;
bool done = false;
ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb3, &done3);
EXPECT_EQ(ret, TDM_ERROR_NONE);
- ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
-
- _tc_tdm_client_virutual_make_available_mode(modes, count);
- ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
-
- ret = tdm_client_voutput_connect(this->voutput);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
+ EXPECT_EQ(ConnectVOutput(mmWidth, mmHeight, this->MODE_COUNT), true);
while (!done)
EXPECT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE);
{
tdm_error ret;
unsigned int mmWidth = 300, mmHeight = 150;
- tdm_client_output_mode modes[this->MODE_COUNT];
- int count = this->MODE_COUNT;
int virtual_conf;
if (this->voutput == NULL) {
return;
}
- ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
-
- _tc_tdm_client_virutual_make_available_mode(modes, count);
- ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
-
- ret = tdm_client_voutput_connect(this->voutput);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
+ EXPECT_EQ(ConnectVOutput(mmWidth, mmHeight, this->MODE_COUNT), true);
tdm_client_handle_events_timeout(this->client, 50);
{
tdm_error ret;
unsigned int mmWidth = 300, mmHeight = 150;
- tdm_client_output_mode modes[this->MODE_COUNT];
- int count = this->MODE_COUNT;
int virtual_conf;
if (this->voutput == NULL) {
return;
}
- ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
-
- _tc_tdm_client_virutual_make_available_mode(modes, count);
- ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
-
- ret = tdm_client_voutput_connect(this->voutput);
- EXPECT_EQ(ret, TDM_ERROR_NONE);
+ EXPECT_EQ(ConnectVOutput(mmWidth, mmHeight, this->MODE_COUNT), true);
tdm_client_handle_events_timeout(this->client, 50);