apicompatanamdw/bcdrivers/os/ossrv/glib/tests/timeloop.c
author shrivatsa
Fri, 27 Aug 2010 14:37:16 +0530
changeset 8 d8ef7a232001
parent 2 0cb2248d0edc
permissions -rw-r--r--
Added Classic UI test cases. Fixes to other existing test cases.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     1
/*
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     3
* All rights reserved.
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     4
* This component and the accompanying materials are made available
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     6
* which accompanies this distribution, and is available
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     8
*
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
     9
* Initial Contributors:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    11
*
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    12
* Contributors:
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    13
*
8
d8ef7a232001 Added Classic UI test cases. Fixes to other existing test cases.
shrivatsa
parents: 2
diff changeset
    14
* Description: 
2
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    15
*
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    16
*/
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    17
#undef G_DISABLE_ASSERT
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    18
#undef G_LOG_DOMAIN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    19
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    20
#include <errno.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    21
#include <stdlib.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    22
#include <unistd.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    23
#include <stdio.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    24
#include <sys/time.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    25
#include <sys/resource.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    26
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    27
#include <glib.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    28
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    29
#ifdef SYMBIAN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    30
#include <glib_global.h>
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    31
#include "mrt2_glib2_test.h"
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    32
#endif /*SYMBIAN*/
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    33
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    34
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    35
static int n_children = 4;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    36
static int n_active_children;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    37
static int n_iters = 5;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    38
static GMainLoop *loop;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    39
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    40
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    41
io_pipe (GIOChannel **channels)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    42
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    43
  int fds[2];
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    44
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    45
  if (pipe(fds) < 0)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    46
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    47
      g_print ("Cannot create pipe %s\n", g_strerror (errno));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    48
      g_assert(FALSE && "timeloop failed");  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    49
    
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    50
#ifdef SYMBIAN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    51
  testResultXml("timeloop");
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    52
#endif /* EMULATOR */
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    53
      exit (1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    54
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    55
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    56
  channels[0] = g_io_channel_unix_new (fds[0]);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    57
  channels[1] = g_io_channel_unix_new (fds[1]);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    58
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    59
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    60
static gboolean
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    61
read_all (GIOChannel *channel, char *buf, int len)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    62
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    63
  gsize bytes_read = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    64
  gsize count;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    65
  GIOError err;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    66
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    67
  while (bytes_read < len)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    68
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    69
      err = g_io_channel_read (channel, buf + bytes_read, len - bytes_read, &count);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    70
      if (err)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    71
	{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    72
	  if (err != G_IO_ERROR_AGAIN)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    73
	  {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    74
	  	g_assert(FALSE && "timeloop failed");
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    75
	    return FALSE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    76
	  }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    77
	}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    78
      else if (count == 0)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    79
	return FALSE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    80
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    81
      bytes_read += count;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    82
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    83
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    84
  return TRUE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    85
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    86
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    87
static gboolean
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    88
write_all (GIOChannel *channel, char *buf, int len)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    89
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    90
  gsize bytes_written = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    91
  gsize count;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    92
  GIOError err;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    93
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    94
  while (bytes_written < len)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    95
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    96
      err = g_io_channel_write (channel, buf + bytes_written, len - bytes_written, &count);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    97
      if (err && err != G_IO_ERROR_AGAIN)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    98
	return FALSE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
    99
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   100
      bytes_written += count;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   101
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   102
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   103
  return TRUE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   104
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   105
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   106
gpointer
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   107
run_child (gpointer data)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   108
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   109
  int i;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   110
  int val = 1;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   111
  GIOChannel *in_channel,*out_channel;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   112
  GTimer *timer = g_timer_new();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   113
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   114
  GIOChannel **channels = data;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   115
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   116
  in_channel = channels[0];
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   117
  out_channel = channels[1];
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   118
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   119
  for (i = 0; i < n_iters; i++)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   120
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   121
      write_all (out_channel, (char *)&val, sizeof (val));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   122
      read_all (in_channel, (char *)&val, sizeof (val));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   123
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   124
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   125
  val = 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   126
  write_all (out_channel, (char *)&val, sizeof (val));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   127
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   128
  val = g_timer_elapsed (timer, NULL) * 1000;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   129
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   130
  write_all (out_channel, (char *)&val, sizeof (val));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   131
  g_timer_destroy (timer);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   132
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   133
  return NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   134
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   135
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   136
static gboolean
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   137
input_callback (GIOChannel   *source,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   138
		GIOCondition  condition,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   139
		gpointer      data)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   140
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   141
  int val;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   142
  GIOChannel *dest = (GIOChannel *)data;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   143
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   144
  if (!read_all (source, (char *)&val, sizeof(val)))
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   145
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   146
      g_print("Unexpected EOF\n");
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   147
      g_assert(FALSE && "timeloop failed");
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   148
    #ifdef SYMBIAN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   149
  testResultXml("timeloop");
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   150
#endif /* EMULATOR */
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   151
      exit (1);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   152
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   153
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   154
  if (val)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   155
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   156
      write_all (dest, (char *)&val, sizeof(val));
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   157
      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   158
      return TRUE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   159
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   160
  else
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   161
    {
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   162
      g_io_channel_close (source);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   163
      g_io_channel_close (dest);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   164
      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   165
      g_io_channel_unref (source);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   166
      g_io_channel_unref (dest);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   167
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   168
      n_active_children--;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   169
      if (n_active_children == 0)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   170
	g_main_loop_quit (loop);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   171
      
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   172
      return FALSE;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   173
    }
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   174
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   175
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   176
static void
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   177
create_child (void)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   178
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   179
  GError *err = NULL;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   180
  GIOChannel *in_channels[2];
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   181
  GIOChannel *out_channels[2];
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   182
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   183
  GIOChannel **sub_channels;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   184
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   185
  sub_channels = g_new (GIOChannel *, 2);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   186
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   187
  io_pipe (in_channels);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   188
  io_pipe (out_channels);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   189
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   190
  sub_channels[0] = in_channels[0];
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   191
  sub_channels[1] = out_channels[1];
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   192
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   193
  g_io_add_watch (out_channels[0], G_IO_IN | G_IO_HUP,
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   194
		      input_callback, in_channels[1]);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   195
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   196
  g_thread_create(run_child,sub_channels,FALSE,&err);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   197
}
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   198
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   199
int 
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   200
main (int argc, char **argv)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   201
{
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   202
  int i;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   203
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   204
  #ifdef SYMBIAN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   205
  g_log_set_handler (NULL,  G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   206
  #endif /*SYMBIAN*/
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   207
	  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   208
  g_thread_init(NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   209
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   210
  if (argc > 1)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   211
    n_children = atoi(argv[1]);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   212
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   213
  if (argc > 2)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   214
    n_iters = atoi(argv[2]);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   215
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   216
  //printf ("Children: %d     Iters: %d\n", n_children, n_iters);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   217
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   218
  n_active_children = n_children;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   219
  for (i = 0; i < n_children; i++)
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   220
    create_child ();
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   221
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   222
  loop = g_main_loop_new (NULL, FALSE);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   223
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   224
  g_assert(loop != NULL);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   225
  
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   226
  g_main_loop_run (loop);
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   227
  #ifdef SYMBIAN
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   228
  testResultXml("timeloop");
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   229
  #endif /* EMULATOR */
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   230
  return 0;
0cb2248d0edc New BC drivers added are - Phonebook, Speed dial utility control, MMS Client MTM, Plugin Bio control, Organizer,
shrivatsa
parents:
diff changeset
   231
}