~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to tests/vmrpcdbg/vmrpcdbg.c

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
static GModule *gPlugin = NULL;
39
39
 
40
 
/* Atomic types are not volatile in old glib versions. */
41
 
#if GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 10
42
 
static volatile gint gRefCount = 0;
43
 
#else
44
 
static gint gRefCount = 0;
45
 
#endif
46
 
 
47
 
 
48
40
/*
49
41
 * Static variables to hold the app's main loop data. CUnit test functions
50
42
 * don't take any parameters so there's no other way to do this...
51
43
 */
52
 
static void (*gRunMainLoop)(gpointer);
53
 
static gpointer gRunData;
 
44
static struct {
 
45
   void (*mainLoop)(gpointer);
 
46
   gpointer          loopData;
 
47
   RpcDebugLibData  *libData;
 
48
   ToolsAppCtx      *ctx;
 
49
   gint              refCount;
 
50
} gLibRunData;
54
51
 
55
52
 
56
53
/*
65
62
static void
66
63
RpcDebugRunLoop(void)
67
64
{
68
 
   ASSERT(gRunMainLoop);
69
 
   ASSERT(gRunData);
70
 
   gRunMainLoop(gRunData);
 
65
   ASSERT(gLibRunData.libData);
 
66
   ASSERT(gLibRunData.mainLoop);
 
67
   ASSERT(gLibRunData.loopData);
 
68
   gLibRunData.mainLoop(gLibRunData.loopData);
 
69
 
 
70
   if (gLibRunData.libData->debugPlugin->shutdownFn != NULL) {
 
71
      gLibRunData.libData->debugPlugin->shutdownFn(gLibRunData.ctx,
 
72
                                                   gLibRunData.libData->debugPlugin);
 
73
   }
71
74
}
72
75
 
73
76
 
110
113
   test = CU_add_test(suite, g_module_name(gPlugin), RpcDebugRunLoop);
111
114
   ASSERT(test != NULL);
112
115
 
113
 
   gRunMainLoop = runMainLoop;
114
 
   gRunData = runData;
 
116
   gLibRunData.ctx = ctx;
 
117
   gLibRunData.libData = ldata;
 
118
   gLibRunData.mainLoop = runMainLoop;
 
119
   gLibRunData.loopData = runData;
115
120
 
116
121
   err = CU_basic_run_tests();
117
122
 
118
123
   /* Clean up internal library / debug plugin state. */
119
 
   ASSERT(g_atomic_int_get(&gRefCount) == 0);
120
 
   ASSERT(ldata != NULL);
121
 
 
122
 
   if (ldata->debugPlugin->shutdownFn != NULL) {
123
 
      ldata->debugPlugin->shutdownFn(ctx, ldata->debugPlugin);
124
 
   }
 
124
   ASSERT(g_atomic_int_get(&gLibRunData.refCount) >= 0);
125
125
 
126
126
   if (gPlugin != NULL) {
127
127
      g_module_close(gPlugin);
133
133
   }
134
134
 
135
135
   CU_cleanup_registry();
 
136
   memset(&gLibRunData, 0, sizeof gLibRunData);
136
137
   return (int) err;
137
138
}
138
139
 
147
148
void
148
149
RpcDebug_DecRef(ToolsAppCtx *ctx)
149
150
{
150
 
   if (g_atomic_int_dec_and_test(&gRefCount)) {
 
151
   if (g_atomic_int_dec_and_test(&gLibRunData.refCount)) {
151
152
      g_main_loop_quit(ctx->mainLoop);
152
153
   }
153
154
}
161
162
void
162
163
RpcDebug_IncRef(void)
163
164
{
164
 
   g_atomic_int_inc(&gRefCount);
 
165
   g_atomic_int_inc(&gLibRunData.refCount);
165
166
}
166
167
 
167
168