<commit_before>/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 *
 *  Gearmand client and server library.
 *
 *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are
 *  met:
 *
 *      * Redistributions of source code must retain the above copyright
 *  notice, this list of conditions and the following disclaimer.
 *
 *      * Redistributions in binary form must reproduce the above
 *  copyright notice, this list of conditions and the following disclaimer
 *  in the documentation and/or other materials provided with the
 *  distribution.
 *
 *      * The names of its contributors may not be used to endorse or
 *  promote products derived from this software without specific prior
 *  written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#include <config.h>
#include <libtest/test.hpp>

using namespace libtest;

#include <libgearman/gearman.h>

#include <libhostile/hostile.h>

#include <tests/start_worker.h>
#include "tests/burnin.h"

#include "tests/workers/v2/echo_or_react.h"

#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <sys/time.h>

#define WORKER_FUNCTION_NAME "foo"

static bool has_hostile()
{
#if defined(HAVE_LIBHOSTILE) && HAVE_LIBHOSTILE
  if (1)
  {
    return true;
  }
#endif

  return false;
}

static in_port_t hostile_server= 0;
static in_port_t stress_server= 0;
static in_port_t& current_server_= stress_server;

static void reset_server()
{
  current_server_= stress_server;
}

static in_port_t current_server()
{
  return current_server_;
}

static void set_server(in_port_t& arg)
{
  current_server_= arg;
}

struct client_thread_context_st
{
  size_t count;
  size_t payload_size;

  client_thread_context_st() :
    count(0),
    payload_size(0)
  { }

  void increment()
  {
    count++;
  }
};

extern "C" {

  static void client_cleanup(void *client)
  {
    int oldstate;
    pthread_setcanceltype(PTHREAD_CANCEL_DISABLE, &oldstate);
    gearman_client_free((gearman_client_st *)client);
    pthread_setcanceltype(oldstate, NULL);
  }

  static void *client_thread(void *object)
  {
    client_thread_context_st *success= (client_thread_context_st *)object;
    fatal_assert(success);
    fatal_assert(success->count == 0);

    gearman_return_t rc;
    gearman_client_st *client;
    {
      int oldstate;
      pthread_setcanceltype(PTHREAD_CANCEL_DISABLE, &oldstate);
      client= gearman_client_create(NULL);

      if (client == NULL)
      {
        pthread_exit(0);
      }
      rc= gearman_client_add_server(client, NULL, current_server());
      pthread_setcanceltype(oldstate, NULL);
    }

    pthread_cleanup_push(client_cleanup, client);

    if (gearman_success(rc))
    {
      gearman_client_set_timeout(client, 400);
      for (size_t x= 0; x < 100; x++)
      {
        int oldstate;
        pthread_setcanceltype(PTHREAD_CANCEL_DISABLE, &oldstate);
        libtest::vchar_t payload;
        payload.resize(success->payload_size);
        void *value= gearman_client_do(client, WORKER_FUNCTION_NAME,
                                       NULL,
                                       &payload[0],
                                       payload.size() ? random() % payload.size() : 0,
                                       NULL, &rc);
        pthread_setcanceltype(oldstate, NULL);

        if (gearman_success(rc))
        {
          success->increment();
        }

        if (value)
        {
          free(value);
        }
      }
    }

    pthread_cleanup_pop(1);
    pthread_exit(0);
  }
}

static bool join_thread(pthread_t& thread_arg, struct timespec& ts)
{
  int error;
  ts.tv_sec+= 10;

  if (HAVE_PTHREAD_TIMEDJOIN_NP)
  {
#if defined(HAVE_PTHREAD_TIMEDJOIN_NP) && HAVE_PTHREAD_TIMEDJOIN_NP
    int limit= 2;
    while (--limit)
    {
      switch ((error= pthread_timedjoin_np(thread_arg, NULL, &ts)))
      {
      case ETIMEDOUT:
        libtest::dream(1, 0);
        continue;

      case 0:
        return true;

      case ESRCH:
        return false;

      default:
        Error << "pthread_timedjoin_np() " << strerror(error);
        return false;
      }
    }

    Out << "pthread_timedjoin_np() " << strerror(error);
    if ((error= pthread_cancel(thread_arg)) != 0)
    {
      Error << "pthread_cancel() " << strerror(error);
      return false;
    }
#endif
  }

  if ((error= pthread_join(thread_arg, NULL)) != 0)
  {
    Error << "pthread_join() " << strerror(error);
    return false;
  }

  return true;
}

static test_return_t worker_ramp_exec(const size_t payload_size)
{
  set_alarm(1200, 0);

  std::vector<pthread_t> children;
  children.resize(number_of_cpus());

  std::vector<client_thread_context_st>  success;
  success.resize(children.size());

  for (size_t x= 0; x < children.size(); x++)
  {
    success[x].payload_size= payload_size;
    pthread_create(&children[x], NULL, client_thread, &success[x]);
  }

  for (size_t x= 0; x < children.size(); x++)
  {
    struct timespec ts;
    bool join_success= false;
    int limit= 2;
    while (join_success == false and --limit)
    {
#if defined(HAVE_LIBRT) && HAVE_LIBRT
      if (HAVE_LIBRT) // This won't be called on OSX, etc,...
      {
        if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
        {
          Error << "clock_gettime(CLOCK_REALTIME) " << strerror(errno);
          continue;
        }

        join_success= join_thread(children[x], ts);
      }
      else
#endif
      {
        struct timeval tv;
        if (gettimeofday(&tv, NULL) == -1)
        {
          Error << "gettimeofday() " << strerror(errno);
          continue;
        }

        TIMEVAL_TO_TIMESPEC(&tv, &ts);
        join_success= join_thread(children[x], ts);
      }
    }

    if (join_success == false)
    {
      pthread_cancel(children[x]);
      Error << "Something went very wrong, it is likely threads were not cleaned up";
    }
  }

  return TEST_SUCCESS;
}

static test_return_t worker_ramp_TEST(void *)
{
  return worker_ramp_exec(0);
}

static test_return_t worker_ramp_1K_TEST(void *)
{
  return worker_ramp_exec(1024);
}

static test_return_t worker_ramp_10K_TEST(void *)
{
  return worker_ramp_exec(1024*10);
}

static test_return_t worker_ramp_SETUP(void *object)
{
  test_skip_valgrind();

  worker_handles_st *handles= (worker_handles_st*)object;

  gearman_function_t echo_react_fn= gearman_function_create(echo_or_react_worker_v2);
  for (uint32_t x= 0; x < 10; x++)
  {
    worker_handle_st *worker;
    if ((worker= test_worker_start(current_server(), NULL, WORKER_FUNCTION_NAME, echo_react_fn, NULL, gearman_worker_options_t())) == NULL)
    {
      return TEST_FAILURE;
    }
    handles->push(worker);
  }

  return TEST_SUCCESS;
}

static test_return_t worker_ramp_TEARDOWN(void* object)
{
  worker_handles_st *handles= (worker_handles_st*)object;
  handles->reset();

  reset_server();

  return TEST_SUCCESS;
}

static test_return_t hostile_gearmand_SETUP(void* object)
{
  test_skip(true, has_hostile());
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  // Programmer error
  assert(hostile_server);

  set_server(hostile_server);
  worker_ramp_SETUP(object);

  return TEST_SUCCESS;
}

static test_return_t recv_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_recv_close(true, 20, 20);

  return TEST_SUCCESS;
}

static test_return_t recv_corrupt_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_recv_corrupt(true, 20, 20);

  return TEST_SUCCESS;
}

static test_return_t resv_TEARDOWN(void* object)
{
  set_recv_close(true, 0, 0);

  worker_handles_st *handles= (worker_handles_st*)object;
  handles->kill_all();

  reset_server();

  return TEST_SUCCESS;
}

static test_return_t send_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_send_close(true, 20, 20);

  return TEST_SUCCESS;
}

static test_return_t accept_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_accept_close(true, 20, 20);

  return TEST_SUCCESS;
}

static test_return_t poll_HOSTILE_POLL_CLOSED_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_poll_close(true, 4, 0, HOSTILE_POLL_CLOSED);

  return TEST_SUCCESS;
}

static test_return_t poll_HOSTILE_POLL_SHUT_WR_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_poll_close(true, 4, 0, HOSTILE_POLL_SHUT_WR);

  return TEST_SUCCESS;
}

static test_return_t poll_HOSTILE_POLL_SHUT_RD_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_poll_close(true, 4, 0, HOSTILE_POLL_SHUT_RD);

  return TEST_SUCCESS;
}

static test_return_t poll_TEARDOWN(void* object)
{
  set_poll_close(false, 0, 0, HOSTILE_POLL_CLOSED);

  worker_handles_st *handles= (worker_handles_st*)object;
  handles->kill_all();

  reset_server();

  return TEST_SUCCESS;
}

static test_return_t send_TEARDOWN(void* object)
{
  set_send_close(true, 0, 0);

  worker_handles_st *handles= (worker_handles_st*)object;
  handles->kill_all();

  reset_server();

  return TEST_SUCCESS;
}

static test_return_t accept_TEARDOWN(void* object)
{
  set_accept_close(true, 0, 0);

  worker_handles_st *handles= (worker_handles_st*)object;
  handles->kill_all();

  reset_server();

  return TEST_SUCCESS;
}

/*********************** World functions **************************************/

static void *world_create(server_startup_st& servers, test_return_t& error)
{
  stress_server= libtest::default_port();
  if (server_startup(servers, "gearmand", stress_server, 0, NULL) == false)
  {
    error= TEST_SKIPPED;
    return NULL;
  }

  if (has_hostile())
  {
    hostile_server= libtest::get_free_port();
    if (server_startup(servers, "gearmand", hostile_server, 0, NULL) == false)
    {
      hostile_server= 0;
    }
  }

  return new worker_handles_st;
}

static bool world_destroy(void *object)
{
  worker_handles_st *handles= (worker_handles_st *)object;
  delete handles;

  return TEST_SUCCESS;
}

test_st burnin_TESTS[] ={
  {"burnin", 0, burnin_TEST },
  {0, 0, 0}
};

test_st worker_TESTS[] ={
  {"first pass", 0, worker_ramp_TEST },
  {"second pass", 0, worker_ramp_TEST },
  {"first pass 1K jobs", 0, worker_ramp_1K_TEST },
  {"first pass 10K jobs", 0, worker_ramp_10K_TEST },
  {0, 0, 0}
};

collection_st collection[] ={
  {"burnin", burnin_setup, burnin_cleanup, burnin_TESTS },
  {"plain", worker_ramp_SETUP, worker_ramp_TEARDOWN, worker_TESTS },
  {"plain against hostile server", hostile_gearmand_SETUP, worker_ramp_TEARDOWN, worker_TESTS },
  {"hostile recv()", recv_SETUP, resv_TEARDOWN, worker_TESTS },
  {"hostile recv() corrupt", recv_corrupt_SETUP, resv_TEARDOWN, worker_TESTS },
  {"hostile send()", send_SETUP, send_TEARDOWN, worker_TESTS },
  {"hostile accept()", accept_SETUP, accept_TEARDOWN, worker_TESTS },
  {"hostile poll(CLOSED)", poll_HOSTILE_POLL_CLOSED_SETUP, poll_TEARDOWN, worker_TESTS },
  {"hostile poll(SHUT_RD)", poll_HOSTILE_POLL_SHUT_RD_SETUP, poll_TEARDOWN, worker_TESTS },
  {"hostile poll(SHUT_WR)", poll_HOSTILE_POLL_SHUT_WR_SETUP, poll_TEARDOWN, worker_TESTS },
  {0, 0, 0, 0}
};

void get_world(libtest::Framework *world)
{
  world->collections(collection);
  world->create(world_create);
  world->destroy(world_destroy);
}
<commit_msg>Fix warning.<commit_after>/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 *
 *  Gearmand client and server library.
 *
 *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are
 *  met:
 *
 *      * Redistributions of source code must retain the above copyright
 *  notice, this list of conditions and the following disclaimer.
 *
 *      * Redistributions in binary form must reproduce the above
 *  copyright notice, this list of conditions and the following disclaimer
 *  in the documentation and/or other materials provided with the
 *  distribution.
 *
 *      * The names of its contributors may not be used to endorse or
 *  promote products derived from this software without specific prior
 *  written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#include <config.h>
#include <libtest/test.hpp>

using namespace libtest;

#include <libgearman/gearman.h>

#include <libhostile/hostile.h>

#include <tests/start_worker.h>
#include "tests/burnin.h"

#include "tests/workers/v2/echo_or_react.h"

#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <sys/time.h>

#define WORKER_FUNCTION_NAME "foo"

static bool has_hostile()
{
#if defined(HAVE_LIBHOSTILE) && HAVE_LIBHOSTILE
  if (1)
  {
    return true;
  }
#endif

  return false;
}

static in_port_t hostile_server= 0;
static in_port_t stress_server= 0;
static in_port_t& current_server_= stress_server;

static void reset_server()
{
  current_server_= stress_server;
}

static in_port_t current_server()
{
  return current_server_;
}

static void set_server(in_port_t& arg)
{
  current_server_= arg;
}

struct client_thread_context_st
{
  size_t count;
  size_t payload_size;

  client_thread_context_st() :
    count(0),
    payload_size(0)
  { }

  void increment()
  {
    count++;
  }
};

extern "C" {

  static void client_cleanup(void *client)
  {
    int oldstate;
    pthread_setcanceltype(PTHREAD_CANCEL_DISABLE, &oldstate);
    gearman_client_free((gearman_client_st *)client);
    pthread_setcanceltype(oldstate, NULL);
  }

  static __attribute__((noreturn)) void *client_thread(void *object)
  {
    client_thread_context_st *success= (client_thread_context_st *)object;
    fatal_assert(success);
    fatal_assert(success->count == 0);

    gearman_return_t rc;
    gearman_client_st *client;
    {
      int oldstate;
      pthread_setcanceltype(PTHREAD_CANCEL_DISABLE, &oldstate);
      client= gearman_client_create(NULL);

      if (client == NULL)
      {
        pthread_exit(0);
      }
      rc= gearman_client_add_server(client, NULL, current_server());
      pthread_setcanceltype(oldstate, NULL);
    }

    pthread_cleanup_push(client_cleanup, client);

    if (gearman_success(rc))
    {
      gearman_client_set_timeout(client, 400);
      for (size_t x= 0; x < 100; x++)
      {
        int oldstate;
        pthread_setcanceltype(PTHREAD_CANCEL_DISABLE, &oldstate);
        libtest::vchar_t payload;
        payload.resize(success->payload_size);
        void *value= gearman_client_do(client, WORKER_FUNCTION_NAME,
                                       NULL,
                                       &payload[0],
                                       payload.size() ? random() % payload.size() : 0,
                                       NULL, &rc);
        pthread_setcanceltype(oldstate, NULL);

        if (gearman_success(rc))
        {
          success->increment();
        }

        if (value)
        {
          free(value);
        }
      }
    }

    pthread_cleanup_pop(1);
    pthread_exit(0);
  }
}

static bool join_thread(pthread_t& thread_arg, struct timespec& ts)
{
  int error;
  ts.tv_sec+= 10;

  if (HAVE_PTHREAD_TIMEDJOIN_NP)
  {
#if defined(HAVE_PTHREAD_TIMEDJOIN_NP) && HAVE_PTHREAD_TIMEDJOIN_NP
    int limit= 2;
    while (--limit)
    {
      switch ((error= pthread_timedjoin_np(thread_arg, NULL, &ts)))
      {
      case ETIMEDOUT:
        libtest::dream(1, 0);
        continue;

      case 0:
        return true;

      case ESRCH:
        return false;

      default:
        Error << "pthread_timedjoin_np() " << strerror(error);
        return false;
      }
    }

    Out << "pthread_timedjoin_np() " << strerror(error);
    if ((error= pthread_cancel(thread_arg)) != 0)
    {
      Error << "pthread_cancel() " << strerror(error);
      return false;
    }
#endif
  }

  if ((error= pthread_join(thread_arg, NULL)) != 0)
  {
    Error << "pthread_join() " << strerror(error);
    return false;
  }

  return true;
}

static test_return_t worker_ramp_exec(const size_t payload_size)
{
  set_alarm(1200, 0);

  std::vector<pthread_t> children;
  children.resize(number_of_cpus());

  std::vector<client_thread_context_st>  success;
  success.resize(children.size());

  for (size_t x= 0; x < children.size(); x++)
  {
    success[x].payload_size= payload_size;
    pthread_create(&children[x], NULL, client_thread, &success[x]);
  }

  for (size_t x= 0; x < children.size(); x++)
  {
    struct timespec ts;
    bool join_success= false;
    int limit= 2;
    while (join_success == false and --limit)
    {
#if defined(HAVE_LIBRT) && HAVE_LIBRT
      if (HAVE_LIBRT) // This won't be called on OSX, etc,...
      {
        if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
        {
          Error << "clock_gettime(CLOCK_REALTIME) " << strerror(errno);
          continue;
        }

        join_success= join_thread(children[x], ts);
      }
      else
#endif
      {
        struct timeval tv;
        if (gettimeofday(&tv, NULL) == -1)
        {
          Error << "gettimeofday() " << strerror(errno);
          continue;
        }

        TIMEVAL_TO_TIMESPEC(&tv, &ts);
        join_success= join_thread(children[x], ts);
      }
    }

    if (join_success == false)
    {
      pthread_cancel(children[x]);
      Error << "Something went very wrong, it is likely threads were not cleaned up";
    }
  }

  return TEST_SUCCESS;
}

static test_return_t worker_ramp_TEST(void *)
{
  return worker_ramp_exec(0);
}

static test_return_t worker_ramp_1K_TEST(void *)
{
  return worker_ramp_exec(1024);
}

static test_return_t worker_ramp_10K_TEST(void *)
{
  return worker_ramp_exec(1024*10);
}

static test_return_t worker_ramp_SETUP(void *object)
{
  test_skip_valgrind();

  worker_handles_st *handles= (worker_handles_st*)object;

  gearman_function_t echo_react_fn= gearman_function_create(echo_or_react_worker_v2);
  for (uint32_t x= 0; x < 10; x++)
  {
    worker_handle_st *worker;
    if ((worker= test_worker_start(current_server(), NULL, WORKER_FUNCTION_NAME, echo_react_fn, NULL, gearman_worker_options_t())) == NULL)
    {
      return TEST_FAILURE;
    }
    handles->push(worker);
  }

  return TEST_SUCCESS;
}

static test_return_t worker_ramp_TEARDOWN(void* object)
{
  worker_handles_st *handles= (worker_handles_st*)object;
  handles->reset();

  reset_server();

  return TEST_SUCCESS;
}

static test_return_t hostile_gearmand_SETUP(void* object)
{
  test_skip(true, has_hostile());
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  // Programmer error
  assert(hostile_server);

  set_server(hostile_server);
  worker_ramp_SETUP(object);

  return TEST_SUCCESS;
}

static test_return_t recv_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_recv_close(true, 20, 20);

  return TEST_SUCCESS;
}

static test_return_t recv_corrupt_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_recv_corrupt(true, 20, 20);

  return TEST_SUCCESS;
}

static test_return_t resv_TEARDOWN(void* object)
{
  set_recv_close(true, 0, 0);

  worker_handles_st *handles= (worker_handles_st*)object;
  handles->kill_all();

  reset_server();

  return TEST_SUCCESS;
}

static test_return_t send_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_send_close(true, 20, 20);

  return TEST_SUCCESS;
}

static test_return_t accept_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_accept_close(true, 20, 20);

  return TEST_SUCCESS;
}

static test_return_t poll_HOSTILE_POLL_CLOSED_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_poll_close(true, 4, 0, HOSTILE_POLL_CLOSED);

  return TEST_SUCCESS;
}

static test_return_t poll_HOSTILE_POLL_SHUT_WR_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_poll_close(true, 4, 0, HOSTILE_POLL_SHUT_WR);

  return TEST_SUCCESS;
}

static test_return_t poll_HOSTILE_POLL_SHUT_RD_SETUP(void* object)
{
  test_skip_valgrind();
  test_skip(true, libtest::is_massive());

  worker_ramp_SETUP(object);
  set_poll_close(true, 4, 0, HOSTILE_POLL_SHUT_RD);

  return TEST_SUCCESS;
}

static test_return_t poll_TEARDOWN(void* object)
{
  set_poll_close(false, 0, 0, HOSTILE_POLL_CLOSED);

  worker_handles_st *handles= (worker_handles_st*)object;
  handles->kill_all();

  reset_server();

  return TEST_SUCCESS;
}

static test_return_t send_TEARDOWN(void* object)
{
  set_send_close(true, 0, 0);

  worker_handles_st *handles= (worker_handles_st*)object;
  handles->kill_all();

  reset_server();

  return TEST_SUCCESS;
}

static test_return_t accept_TEARDOWN(void* object)
{
  set_accept_close(true, 0, 0);

  worker_handles_st *handles= (worker_handles_st*)object;
  handles->kill_all();

  reset_server();

  return TEST_SUCCESS;
}

/*********************** World functions **************************************/

static void *world_create(server_startup_st& servers, test_return_t& error)
{
  stress_server= libtest::default_port();
  if (server_startup(servers, "gearmand", stress_server, 0, NULL) == false)
  {
    error= TEST_SKIPPED;
    return NULL;
  }

  if (has_hostile())
  {
    hostile_server= libtest::get_free_port();
    if (server_startup(servers, "gearmand", hostile_server, 0, NULL) == false)
    {
      hostile_server= 0;
    }
  }

  return new worker_handles_st;
}

static bool world_destroy(void *object)
{
  worker_handles_st *handles= (worker_handles_st *)object;
  delete handles;

  return TEST_SUCCESS;
}

test_st burnin_TESTS[] ={
  {"burnin", 0, burnin_TEST },
  {0, 0, 0}
};

test_st worker_TESTS[] ={
  {"first pass", 0, worker_ramp_TEST },
  {"second pass", 0, worker_ramp_TEST },
  {"first pass 1K jobs", 0, worker_ramp_1K_TEST },
  {"first pass 10K jobs", 0, worker_ramp_10K_TEST },
  {0, 0, 0}
};

collection_st collection[] ={
  {"burnin", burnin_setup, burnin_cleanup, burnin_TESTS },
  {"plain", worker_ramp_SETUP, worker_ramp_TEARDOWN, worker_TESTS },
  {"plain against hostile server", hostile_gearmand_SETUP, worker_ramp_TEARDOWN, worker_TESTS },
  {"hostile recv()", recv_SETUP, resv_TEARDOWN, worker_TESTS },
  {"hostile recv() corrupt", recv_corrupt_SETUP, resv_TEARDOWN, worker_TESTS },
  {"hostile send()", send_SETUP, send_TEARDOWN, worker_TESTS },
  {"hostile accept()", accept_SETUP, accept_TEARDOWN, worker_TESTS },
  {"hostile poll(CLOSED)", poll_HOSTILE_POLL_CLOSED_SETUP, poll_TEARDOWN, worker_TESTS },
  {"hostile poll(SHUT_RD)", poll_HOSTILE_POLL_SHUT_RD_SETUP, poll_TEARDOWN, worker_TESTS },
  {"hostile poll(SHUT_WR)", poll_HOSTILE_POLL_SHUT_WR_SETUP, poll_TEARDOWN, worker_TESTS },
  {0, 0, 0, 0}
};

void get_world(libtest::Framework *world)
{
  world->collections(collection);
  world->create(world_create);
  world->destroy(world_destroy);
}
<|endoftext|>


<commit_before>//
// Copyright (c) 2018 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation.  All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include "sys_net_native.h"

static const CLR_RT_MethodHandler method_lookup[] =
{
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011ConfigurationCount___STATIC__I4,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011Configuration___STATIC__SystemNetNetworkInformationWireless80211Configuration__I4,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::UpdateConfiguration___STATIC__VOID,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::InitializeNetworkInterfaceSettings___VOID,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::UpdateConfiguration___VOID__I4,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterfaceCount___STATIC__I4,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterface___STATIC__SystemNetNetworkInformationNetworkInterface__U4,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::IPAddressFromString___STATIC__U4__STRING,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_Security_CertificateManager::AddCaCertificateBundle___STATIC__BOOLEAN__SZARRAY_U1,
    Library_sys_net_native_System_Net_Security_SslNative::SecureServerInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate,
    Library_sys_net_native_System_Net_Security_SslNative::SecureClientInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate,
    Library_sys_net_native_System_Net_Security_SslNative::SecureAccept___STATIC__VOID__I4__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::SecureConnect___STATIC__VOID__I4__STRING__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::SecureRead___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::SecureWrite___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::SecureCloseSocket___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::ExitSecureContext___STATIC__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::DataAvailable___STATIC__I4__OBJECT,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::socket___STATIC__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::bind___STATIC__VOID__OBJECT__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::connect___STATIC__VOID__OBJECT__SZARRAY_U1__BOOLEAN,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::send___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::recv___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::close___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::listen___STATIC__VOID__OBJECT__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::accept___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getaddrinfo___STATIC__VOID__STRING__BYREF_STRING__BYREF_SZARRAY_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::shutdown___STATIC__VOID__OBJECT__I4__BYREF_I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::sendto___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::recvfrom___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getpeername___STATIC__VOID__OBJECT__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getsockname___STATIC__VOID__OBJECT__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::setsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::poll___STATIC__BOOLEAN__OBJECT__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::ioctl___STATIC__VOID__OBJECT__U4__BYREF_U4,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate::ParseCertificate___STATIC__VOID__SZARRAY_U1__STRING__BYREF_STRING__BYREF_STRING__BYREF_mscorlibSystemDateTime__BYREF_mscorlibSystemDateTime,
    NULL,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Net =
{
    "System.Net",
    0x001C1FB9,
    method_lookup,
    { 1, 0, 5, 0 }
};
<commit_msg>Update nanoFramework.System.Net version to 1.0.6-preview-003 ***NO_CI***<commit_after>//
// Copyright (c) 2018 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation.  All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include "sys_net_native.h"

static const CLR_RT_MethodHandler method_lookup[] =
{
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011ConfigurationCount___STATIC__I4,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011Configuration___STATIC__SystemNetNetworkInformationWireless80211Configuration__I4,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::UpdateConfiguration___STATIC__VOID,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::InitializeNetworkInterfaceSettings___VOID,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::UpdateConfiguration___VOID__I4,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterfaceCount___STATIC__I4,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterface___STATIC__SystemNetNetworkInformationNetworkInterface__U4,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::IPAddressFromString___STATIC__U4__STRING,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_Security_CertificateManager::AddCaCertificateBundle___STATIC__BOOLEAN__SZARRAY_U1,
    Library_sys_net_native_System_Net_Security_SslNative::SecureServerInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate,
    Library_sys_net_native_System_Net_Security_SslNative::SecureClientInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate,
    Library_sys_net_native_System_Net_Security_SslNative::SecureAccept___STATIC__VOID__I4__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::SecureConnect___STATIC__VOID__I4__STRING__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::SecureRead___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::SecureWrite___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::SecureCloseSocket___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::ExitSecureContext___STATIC__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::DataAvailable___STATIC__I4__OBJECT,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::socket___STATIC__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::bind___STATIC__VOID__OBJECT__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::connect___STATIC__VOID__OBJECT__SZARRAY_U1__BOOLEAN,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::send___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::recv___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::close___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::listen___STATIC__VOID__OBJECT__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::accept___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getaddrinfo___STATIC__VOID__STRING__BYREF_STRING__BYREF_SZARRAY_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::shutdown___STATIC__VOID__OBJECT__I4__BYREF_I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::sendto___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::recvfrom___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getpeername___STATIC__VOID__OBJECT__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getsockname___STATIC__VOID__OBJECT__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::setsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::poll___STATIC__BOOLEAN__OBJECT__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::ioctl___STATIC__VOID__OBJECT__U4__BYREF_U4,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate::ParseCertificate___STATIC__VOID__SZARRAY_U1__STRING__BYREF_STRING__BYREF_STRING__BYREF_mscorlibSystemDateTime__BYREF_mscorlibSystemDateTime,
    NULL,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Net =
{
    "System.Net",
    0x001C1FB9,
    method_lookup,
    { 1, 0, 6, 0 }
};
<|endoftext|>


<commit_before>//
// Copyright (c) 2018 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation.  All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include "sys_net_native.h"

static const CLR_RT_MethodHandler method_lookup[] =
{
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011ConfigurationCount___STATIC__I4,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011Configuration___STATIC__SystemNetNetworkInformationWireless80211Configuration__I4,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::UpdateConfiguration___STATIC__VOID,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::InitializeNetworkInterfaceSettings___VOID,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::UpdateConfiguration___VOID__I4,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterfaceCount___STATIC__I4,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterface___STATIC__SystemNetNetworkInformationNetworkInterface__U4,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::IPAddressFromString___STATIC__U4__STRING,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_Security_CertificateManager::AddCaCertificateBundle___STATIC__BOOLEAN__SZARRAY_U1,
    Library_sys_net_native_System_Net_Security_SslNative::SecureServerInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate,
    Library_sys_net_native_System_Net_Security_SslNative::SecureClientInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate,
    Library_sys_net_native_System_Net_Security_SslNative::SecureAccept___STATIC__VOID__I4__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::SecureConnect___STATIC__VOID__I4__STRING__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::SecureRead___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::SecureWrite___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::SecureCloseSocket___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::ExitSecureContext___STATIC__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::DataAvailable___STATIC__I4__OBJECT,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::socket___STATIC__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::bind___STATIC__VOID__OBJECT__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::connect___STATIC__VOID__OBJECT__SZARRAY_U1__BOOLEAN,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::send___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::recv___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::close___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::listen___STATIC__VOID__OBJECT__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::accept___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getaddrinfo___STATIC__VOID__STRING__BYREF_STRING__BYREF_SZARRAY_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::shutdown___STATIC__VOID__OBJECT__I4__BYREF_I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::sendto___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::recvfrom___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getpeername___STATIC__VOID__OBJECT__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getsockname___STATIC__VOID__OBJECT__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::setsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::poll___STATIC__BOOLEAN__OBJECT__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::ioctl___STATIC__VOID__OBJECT__U4__BYREF_U4,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate::ParseCertificate___STATIC__VOID__SZARRAY_U1__STRING__BYREF_STRING__BYREF_STRING__BYREF_mscorlibSystemDateTime__BYREF_mscorlibSystemDateTime,
    NULL,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Net =
{
    "System.Net",
    0x001C1FB9,
    method_lookup,
    { 1, 0, 6, 0 }
};
<commit_msg>Update nanoFramework.System.Net version to 1.0.6-preview-009 ***NO_CI***<commit_after>//
// Copyright (c) 2018 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation.  All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include "sys_net_native.h"

static const CLR_RT_MethodHandler method_lookup[] =
{
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011ConfigurationCount___STATIC__I4,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::GetWireless82011Configuration___STATIC__SystemNetNetworkInformationWireless80211Configuration__I4,
    Library_sys_net_native_System_Net_NetworkInformation_Wireless80211Configuration::UpdateConfiguration___STATIC__VOID,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::InitializeNetworkInterfaceSettings___VOID,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::UpdateConfiguration___VOID__I4,
    NULL,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterfaceCount___STATIC__I4,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::GetNetworkInterface___STATIC__SystemNetNetworkInformationNetworkInterface__U4,
    Library_sys_net_native_System_Net_NetworkInformation_NetworkInterface::IPAddressFromString___STATIC__U4__STRING,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_Security_CertificateManager::AddCaCertificateBundle___STATIC__BOOLEAN__SZARRAY_U1,
    Library_sys_net_native_System_Net_Security_SslNative::SecureServerInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate,
    Library_sys_net_native_System_Net_Security_SslNative::SecureClientInit___STATIC__I4__I4__I4__SystemSecurityCryptographyX509CertificatesX509Certificate__SystemSecurityCryptographyX509CertificatesX509Certificate,
    Library_sys_net_native_System_Net_Security_SslNative::SecureAccept___STATIC__VOID__I4__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::SecureConnect___STATIC__VOID__I4__STRING__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::SecureRead___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::SecureWrite___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::SecureCloseSocket___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Security_SslNative::ExitSecureContext___STATIC__I4__I4,
    Library_sys_net_native_System_Net_Security_SslNative::DataAvailable___STATIC__I4__OBJECT,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::socket___STATIC__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::bind___STATIC__VOID__OBJECT__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::connect___STATIC__VOID__OBJECT__SZARRAY_U1__BOOLEAN,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::send___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::recv___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::close___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::listen___STATIC__VOID__OBJECT__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::accept___STATIC__I4__OBJECT,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getaddrinfo___STATIC__VOID__STRING__BYREF_STRING__BYREF_SZARRAY_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::shutdown___STATIC__VOID__OBJECT__I4__BYREF_I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::sendto___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::recvfrom___STATIC__I4__OBJECT__SZARRAY_U1__I4__I4__I4__I4__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getpeername___STATIC__VOID__OBJECT__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getsockname___STATIC__VOID__OBJECT__BYREF_SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::getsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::setsockopt___STATIC__VOID__OBJECT__I4__I4__SZARRAY_U1,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::poll___STATIC__BOOLEAN__OBJECT__I4__I4,
    Library_sys_net_native_System_Net_Sockets_NativeSocket::ioctl___STATIC__VOID__OBJECT__U4__BYREF_U4,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    Library_sys_net_native_System_Security_Cryptography_X509Certificates_X509Certificate::ParseCertificate___STATIC__VOID__SZARRAY_U1__STRING__BYREF_STRING__BYREF_STRING__BYREF_mscorlibSystemDateTime__BYREF_mscorlibSystemDateTime,
    NULL,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Net =
{
    "System.Net",
    0x3E9CB40D,
    method_lookup,
    { 1, 0, 6, 0 }
};
<|endoftext|>


<commit_before>#pragma once
#include <boost/preprocessor.hpp>
#include <type_traits>

// 内部使用
#define DefineEnum_Postfix(name, seq) \
			_Num = BOOST_PP_SEQ_SIZE(seq) \
		} value; \
		name() = default; \
		name(const name&) = default; \
		name(const e& n): value(n) {} \
		operator e () const noexcept { return value; } \
		using serialize_t = std::underlying_type_t<e>; \
		template <class Ar> \
		serialize_t save_minimal(const Ar&) const noexcept { return value; } \
		template <class Ar> \
		void load_minimal(const Ar&, const serialize_t& v) noexcept { value=static_cast<e>(v); } \
	}

//! Enum定義
/*!
	DefineEnum(MyEnum, (AAA)(BBB)(CCC));
	と記述すると
	struct MyEnum {
		enum e {
			AAA,
			BBB,
			CCC,
			_Num = 3
		} value;
	};
	のような形で定義される
*/
#define DefineEnum(name, seq) \
	struct name { \
		enum e { \
			BOOST_PP_SEQ_ENUM(seq), \
			DefineEnum_Postfix(name,seq)

// 内部使用
#define DefineEnumPair_func(r, data, elem) BOOST_PP_SEQ_ELEM(0,elem)=BOOST_PP_SEQ_ELEM(1,elem),
//! 値を明示的に指定するEnum定義
/*!
	DefineEnum(
		MyEnum,
		((AAA)(100))
		((BBB)(200))
		((CCC)(300))
	);
	と記述すると
	struct MyEnum {
		enum e {
			AAA = 100,
			BBB = 200,
			CCC = 300,
			_Num = 3
		} value;
	};
	のような形で定義される
*/
#define DefineEnumPair(name, seq) \
	struct name { \
		enum e { \
			BOOST_PP_SEQ_FOR_EACH(DefineEnumPair_func, 0, seq) \
			DefineEnum_Postfix(name, seq)
<commit_msg>コメントtypo修正<commit_after>#pragma once
#include <boost/preprocessor.hpp>
#include <type_traits>

// 内部使用
#define DefineEnum_Postfix(name, seq) \
			_Num = BOOST_PP_SEQ_SIZE(seq) \
		} value; \
		name() = default; \
		name(const name&) = default; \
		name(const e& n): value(n) {} \
		operator e () const noexcept { return value; } \
		using serialize_t = std::underlying_type_t<e>; \
		template <class Ar> \
		serialize_t save_minimal(const Ar&) const noexcept { return value; } \
		template <class Ar> \
		void load_minimal(const Ar&, const serialize_t& v) noexcept { value=static_cast<e>(v); } \
	}

//! Enum定義
/*!
	DefineEnum(MyEnum, (AAA)(BBB)(CCC));
	と記述すると
	struct MyEnum {
		enum e {
			AAA,
			BBB,
			CCC,
			_Num = 3
		} value;
	};
	のような形で定義される
*/
#define DefineEnum(name, seq) \
	struct name { \
		enum e { \
			BOOST_PP_SEQ_ENUM(seq), \
			DefineEnum_Postfix(name,seq)

// 内部使用
#define DefineEnumPair_func(r, data, elem) BOOST_PP_SEQ_ELEM(0,elem)=BOOST_PP_SEQ_ELEM(1,elem),
//! 値を明示的に指定するEnum定義
/*!
	DefineEnumPair(
		MyEnum,
		((AAA)(100))
		((BBB)(200))
		((CCC)(300))
	);
	と記述すると
	struct MyEnum {
		enum e {
			AAA = 100,
			BBB = 200,
			CCC = 300,
			_Num = 3
		} value;
	};
	のような形で定義される
*/
#define DefineEnumPair(name, seq) \
	struct name { \
		enum e { \
			BOOST_PP_SEQ_FOR_EACH(DefineEnumPair_func, 0, seq) \
			DefineEnum_Postfix(name, seq)
<|endoftext|>


<commit_before>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPythonAppInit.cxx

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

/* Minimal main program -- everything is loaded from the library */

#include "Python.h"

#ifdef VTK_COMPILED_USING_MPI
# include <mpi.h>
# include "vtkMPIController.h"
#endif // VTK_COMPILED_USING_MPI

#include "vtkVersion.h"
#include "Wrapping/Python/vtkPythonAppInitConfigure.h"

#if defined(CMAKE_INTDIR)
# define VTK_PYTHON_LIBRARY_DIR VTK_PYTHON_LIBRARY_DIR_BUILD "/" CMAKE_INTDIR
#else
# define VTK_PYTHON_LIBRARY_DIR VTK_PYTHON_LIBRARY_DIR_BUILD
#endif

#include <sys/stat.h>

/*
 * Make sure all the kits register their classes with vtkInstantiator.
 */
#include "vtkCommonInstantiator.h"
#include "vtkFilteringInstantiator.h"
#include "vtkIOInstantiator.h"
#include "vtkImagingInstantiator.h"
#include "vtkGraphicsInstantiator.h"

#ifdef VTK_USE_RENDERING
#include "vtkRenderingInstantiator.h"
#endif

#ifdef VTK_USE_PATENTED
#include "vtkPatentedInstantiator.h"
#endif

#ifdef VTK_USE_HYBRID
#include "vtkHybridInstantiator.h"
#endif

#ifdef VTK_USE_PARALLEL
#include "vtkParallelInstantiator.h"
#endif

#ifdef VTK_COMPILED_USING_MPI
class vtkMPICleanup {
public:
  vtkMPICleanup()
    {
      this->Controller = 0;
    }
  void Initialize(int* argc, char ***argv)
    {
      MPI_Init(argc, argv);
      this->Controller = vtkMPIController::New();
      this->Controller->Initialize(argc, argv, 1);
      vtkMultiProcessController::SetGlobalController(this->Controller);
    }
  ~vtkMPICleanup()
    {
      if ( this->Controller )
        {
        this->Controller->Finalize();
        this->Controller->Delete();
        }
    }
private:
  vtkMPIController *Controller;
};

static vtkMPICleanup VTKMPICleanup;

#endif // VTK_COMPILED_USING_MPI

extern "C" {
  extern DL_EXPORT(int) Py_Main(int, char **);
}

static void vtkPythonAppInitEnableMSVCDebugHook();
static int vtkPythonAppInitFileExists(const char* filename);

int main(int argc, char **argv)
{
  vtkPythonAppInitEnableMSVCDebugHook();

#ifdef VTK_COMPILED_USING_MPI
  VTKMPICleanup.Initialize(&argc, &argv);
#endif // VTK_COMPILED_USING_MPI

  int displayVersion = 0;
  if ( argc > 1 )
    {
    int cc;
    for ( cc = 1; cc < argc; cc ++ )
      {
      if ( strcmp(argv[cc], "-V") == 0 )
        {
        displayVersion = 1;
        break;
        }
      }
    }
  else
    {
    displayVersion = 1;
    }
  if ( displayVersion )
    {
    cout << vtkVersion::GetVTKSourceVersion() << endl;
    }

  // The following code will hack in the path for running VTK/Python
  // from the build tree. Do not try this at home. We are
  // professionals.

  // Set the program name, so that we can ask python to provide us
  // full path.
  Py_SetProgramName(argv[0]);

  // Initialize interpreter.
  Py_Initialize();

  // If the location of the library path and wrapping path exist, add
  // them to the list.

  // Get the pointer to path list object, append both paths, and
  // make sure to decrease reference counting for both path strings.
  char tmpPath[5];
  sprintf(tmpPath,"path");
  PyObject* path = PySys_GetObject(tmpPath);
  PyObject* newpath;
  if ( ::vtkPythonAppInitFileExists(VTK_PYTHON_LIBRARY_DIR) )
    {
    newpath = PyString_FromString(VTK_PYTHON_LIBRARY_DIR);
    PyList_Insert(path, 0, newpath);
    Py_DECREF(newpath);
    }
  if ( ::vtkPythonAppInitFileExists(VTK_PYTHON_PACKAGE_DIR) )
    {
    newpath = PyString_FromString(VTK_PYTHON_PACKAGE_DIR);
    PyList_Insert(path, 0, newpath);
    Py_DECREF(newpath);
    }

  // Ok, all done, now enter python main.
  return Py_Main(argc, argv);
}

int vtkPythonAppInitFileExists(const char* filename)
{
  // Return true if the file exists.
  struct stat fs;
  if (stat(filename, &fs) != 0)
    {
    return 0;
    }
  return 1;
}

// For a DEBUG build on MSVC, add a hook to prevent error dialogs when
// being run from DART.
#if defined(_MSC_VER) && defined(_DEBUG)
# include <crtdbg.h>
static int vtkPythonAppInitDebugReport(int, char* message, int*)
{
  fprintf(stderr, message);
  exit(1);
  return 0;
}
void vtkPythonAppInitEnableMSVCDebugHook()
{
  if(getenv("DART_TEST_FROM_DART"))
    {
    _CrtSetReportHook(vtkPythonAppInitDebugReport);
    }
}
#else
void vtkPythonAppInitEnableMSVCDebugHook()
{
}
#endif
<commit_msg>fix for python 23<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPythonAppInit.cxx

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

/* Minimal main program -- everything is loaded from the library */

#include "Python.h"

#ifdef VTK_COMPILED_USING_MPI
# include <mpi.h>
# include "vtkMPIController.h"
#endif // VTK_COMPILED_USING_MPI

#include "vtkVersion.h"
#include "Wrapping/Python/vtkPythonAppInitConfigure.h"

#if defined(CMAKE_INTDIR)
# define VTK_PYTHON_LIBRARY_DIR VTK_PYTHON_LIBRARY_DIR_BUILD "/" CMAKE_INTDIR
#else
# define VTK_PYTHON_LIBRARY_DIR VTK_PYTHON_LIBRARY_DIR_BUILD
#endif

#include <sys/stat.h>

/*
 * Make sure all the kits register their classes with vtkInstantiator.
 */
#include "vtkCommonInstantiator.h"
#include "vtkFilteringInstantiator.h"
#include "vtkIOInstantiator.h"
#include "vtkImagingInstantiator.h"
#include "vtkGraphicsInstantiator.h"

#ifdef VTK_USE_RENDERING
#include "vtkRenderingInstantiator.h"
#endif

#ifdef VTK_USE_PATENTED
#include "vtkPatentedInstantiator.h"
#endif

#ifdef VTK_USE_HYBRID
#include "vtkHybridInstantiator.h"
#endif

#ifdef VTK_USE_PARALLEL
#include "vtkParallelInstantiator.h"
#endif

#ifdef VTK_COMPILED_USING_MPI
class vtkMPICleanup {
public:
  vtkMPICleanup()
    {
      this->Controller = 0;
    }
  void Initialize(int* argc, char ***argv)
    {
      MPI_Init(argc, argv);
      this->Controller = vtkMPIController::New();
      this->Controller->Initialize(argc, argv, 1);
      vtkMultiProcessController::SetGlobalController(this->Controller);
    }
  ~vtkMPICleanup()
    {
      if ( this->Controller )
        {
        this->Controller->Finalize();
        this->Controller->Delete();
        }
    }
private:
  vtkMPIController *Controller;
};

static vtkMPICleanup VTKMPICleanup;

#endif // VTK_COMPILED_USING_MPI

extern "C" {
  extern DL_IMPORT(int) Py_Main(int, char **);
}

static void vtkPythonAppInitEnableMSVCDebugHook();
static int vtkPythonAppInitFileExists(const char* filename);

int main(int argc, char **argv)
{
  vtkPythonAppInitEnableMSVCDebugHook();

#ifdef VTK_COMPILED_USING_MPI
  VTKMPICleanup.Initialize(&argc, &argv);
#endif // VTK_COMPILED_USING_MPI

  int displayVersion = 0;
  if ( argc > 1 )
    {
    int cc;
    for ( cc = 1; cc < argc; cc ++ )
      {
      if ( strcmp(argv[cc], "-V") == 0 )
        {
        displayVersion = 1;
        break;
        }
      }
    }
  else
    {
    displayVersion = 1;
    }
  if ( displayVersion )
    {
    cout << vtkVersion::GetVTKSourceVersion() << endl;
    }

  // The following code will hack in the path for running VTK/Python
  // from the build tree. Do not try this at home. We are
  // professionals.

  // Set the program name, so that we can ask python to provide us
  // full path.
  Py_SetProgramName(argv[0]);

  // Initialize interpreter.
  Py_Initialize();

  // If the location of the library path and wrapping path exist, add
  // them to the list.

  // Get the pointer to path list object, append both paths, and
  // make sure to decrease reference counting for both path strings.
  char tmpPath[5];
  sprintf(tmpPath,"path");
  PyObject* path = PySys_GetObject(tmpPath);
  PyObject* newpath;
  if ( ::vtkPythonAppInitFileExists(VTK_PYTHON_LIBRARY_DIR) )
    {
    newpath = PyString_FromString(VTK_PYTHON_LIBRARY_DIR);
    PyList_Insert(path, 0, newpath);
    Py_DECREF(newpath);
    }
  if ( ::vtkPythonAppInitFileExists(VTK_PYTHON_PACKAGE_DIR) )
    {
    newpath = PyString_FromString(VTK_PYTHON_PACKAGE_DIR);
    PyList_Insert(path, 0, newpath);
    Py_DECREF(newpath);
    }

  // Ok, all done, now enter python main.
  return Py_Main(argc, argv);
}

int vtkPythonAppInitFileExists(const char* filename)
{
  // Return true if the file exists.
  struct stat fs;
  if (stat(filename, &fs) != 0)
    {
    return 0;
    }
  return 1;
}

// For a DEBUG build on MSVC, add a hook to prevent error dialogs when
// being run from DART.
#if defined(_MSC_VER) && defined(_DEBUG)
# include <crtdbg.h>
static int vtkPythonAppInitDebugReport(int, char* message, int*)
{
  fprintf(stderr, message);
  exit(1);
  return 0;
}
void vtkPythonAppInitEnableMSVCDebugHook()
{
  if(getenv("DART_TEST_FROM_DART"))
    {
    _CrtSetReportHook(vtkPythonAppInitDebugReport);
    }
}
#else
void vtkPythonAppInitEnableMSVCDebugHook()
{
}
#endif
<|endoftext|>


<commit_before>#include "mainMenuWidget.h"

MainMenuWidget::MainMenuWidget()
{
	// Allows keyboard input to fall through
    setFocusPolicy( Qt::ClickFocus );

    // Create Images
    m_imgBackground = new QPixmap( "images/Background.jpg" );
    m_imgLeftPlayer = new QPixmap( "images/PlayerLeft.png" );
    m_imgRightPlayer = new QPixmap( "images/PlayerRight.png" );
    m_imgNhlLogo = new QPixmap( "images/NHLLogo.png" );

    // Create Labels
    m_lbBackground = new QLabel( this );
    m_lbBackground->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbBackground->setPixmap( *m_imgBackground );
    m_lbBackground->setScaledContents( true );

    m_lbNhlLogo = new QLabel( this );
    m_lbNhlLogo->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbNhlLogo->setPixmap( *m_imgNhlLogo );
    m_lbNhlLogo->setScaledContents( true );

    m_lbLeftPlayer = new QLabel( this );
    m_lbLeftPlayer->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbLeftPlayer->setPixmap( *m_imgLeftPlayer );
    m_lbLeftPlayer->setScaledContents( true );

    m_lbRightPlayer = new QLabel( this );
    m_lbRightPlayer->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbRightPlayer->setPixmap( *m_imgRightPlayer );
    m_lbRightPlayer->setScaledContents( true );

  	QFont NHLFont( "NHL", 20 );
    // Create Menu Buttons
	m_btnSinglePlayer = new QPushButton( "SINGLE PLAYER", this );
	m_btnSinglePlayer->setFont( NHLFont );
	m_btnSinglePlayer->setFlat( true );
	m_btnTwoPlayer = new QPushButton( "VERSUS MODE", this );
	m_btnTwoPlayer->setFont( NHLFont );
	m_btnTwoPlayer->setFlat( true );
	m_btnExit = new QPushButton( "EXIT GAME", this );
	m_btnExit->setFont( NHLFont );
	m_btnExit->setFlat( true );

	resize();

	connect( m_btnSinglePlayer, SIGNAL ( released() ),
		this, SIGNAL ( clickedSinglePlayer() ) );
	connect( m_btnTwoPlayer, SIGNAL ( released() ),
		this, SIGNAL ( clickedTwoPlayer() ) );
	connect( m_btnExit, SIGNAL ( released() ),
		this, SIGNAL ( clickedExit() ) );
}

MainMenuWidget::~MainMenuWidget()
{
    delete m_lbBackground;
    delete m_lbLeftPlayer;
    delete m_lbRightPlayer;
    delete m_lbNhlLogo;

	delete m_btnSinglePlayer;
	delete m_btnTwoPlayer;
	delete m_btnExit;

    delete m_imgBackground;
    delete m_imgLeftPlayer;
    delete m_imgRightPlayer;
    delete m_imgNhlLogo;
}

void MainMenuWidget::resizeEvent( QResizeEvent* event )
{
	(void)event;

	resize();
}

void MainMenuWidget::resize()
{
	m_lbBackground->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
	m_lbNhlLogo->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbLeftPlayer->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbRightPlayer->setGeometry( 0, 0, QWidget::width(), QWidget::height() );

	m_btnSinglePlayer->setGeometry(
		QWidget::width() / 2 - m_btnSinglePlayer->width() / 2,
		QWidget::height() - m_btnSinglePlayer->height() / 2 - 150, 250, 40);
	m_btnTwoPlayer->setGeometry(
		QWidget::width() / 2 - m_btnTwoPlayer->width() / 2,
		QWidget::height() - m_btnTwoPlayer->height() / 2 - 100, 250, 40 );
	m_btnExit->setGeometry( QWidget::width() / 2 - m_btnExit->width() / 2,
		QWidget::height() - m_btnExit->height() / 2 - 50, 250, 40 );
}<commit_msg>fixed button colors<commit_after>#include "mainMenuWidget.h"

MainMenuWidget::MainMenuWidget()
{
	// Allows keyboard input to fall through
    setFocusPolicy( Qt::ClickFocus );

    // Create Images
    m_imgBackground = new QPixmap( "images/Background.jpg" );
    m_imgLeftPlayer = new QPixmap( "images/PlayerLeft.png" );
    m_imgRightPlayer = new QPixmap( "images/PlayerRight.png" );
    m_imgNhlLogo = new QPixmap( "images/NHLLogo.png" );

    // Create Labels
    m_lbBackground = new QLabel( this );
    m_lbBackground->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbBackground->setPixmap( *m_imgBackground );
    m_lbBackground->setScaledContents( true );

    m_lbNhlLogo = new QLabel( this );
    m_lbNhlLogo->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbNhlLogo->setPixmap( *m_imgNhlLogo );
    m_lbNhlLogo->setScaledContents( true );

    m_lbLeftPlayer = new QLabel( this );
    m_lbLeftPlayer->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbLeftPlayer->setPixmap( *m_imgLeftPlayer );
    m_lbLeftPlayer->setScaledContents( true );

    m_lbRightPlayer = new QLabel( this );
    m_lbRightPlayer->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbRightPlayer->setPixmap( *m_imgRightPlayer );
    m_lbRightPlayer->setScaledContents( true );

  	QFont NHLFont( "NHL", 20 );
    // Create Menu Buttons
	m_btnSinglePlayer = new QPushButton( "SINGLE PLAYER", this );
	m_btnSinglePlayer->setFont( NHLFont );
	m_btnSinglePlayer->setFlat( true );
	m_btnSinglePlayer->setStyleSheet("color: blue");
	m_btnTwoPlayer = new QPushButton( "VERSUS MODE", this );
	m_btnTwoPlayer->setFont( NHLFont );
	m_btnTwoPlayer->setFlat( true );
	m_btnTwoPlayer->setStyleSheet("color: blue");
	m_btnExit = new QPushButton( "EXIT GAME", this );
	m_btnExit->setFont( NHLFont );
	m_btnExit->setFlat( true );
	m_btnExit->setStyleSheet("color: blue");

	resize();

	connect( m_btnSinglePlayer, SIGNAL ( released() ),
		this, SIGNAL ( clickedSinglePlayer() ) );
	connect( m_btnTwoPlayer, SIGNAL ( released() ),
		this, SIGNAL ( clickedTwoPlayer() ) );
	connect( m_btnExit, SIGNAL ( released() ),
		this, SIGNAL ( clickedExit() ) );
}

MainMenuWidget::~MainMenuWidget()
{
    delete m_lbBackground;
    delete m_lbLeftPlayer;
    delete m_lbRightPlayer;
    delete m_lbNhlLogo;

	delete m_btnSinglePlayer;
	delete m_btnTwoPlayer;
	delete m_btnExit;

    delete m_imgBackground;
    delete m_imgLeftPlayer;
    delete m_imgRightPlayer;
    delete m_imgNhlLogo;
}

void MainMenuWidget::resizeEvent( QResizeEvent* event )
{
	(void)event;

	resize();
}

void MainMenuWidget::resize()
{
	m_lbBackground->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
	m_lbNhlLogo->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbLeftPlayer->setGeometry( 0, 0, QWidget::width(), QWidget::height() );
    m_lbRightPlayer->setGeometry( 0, 0, QWidget::width(), QWidget::height() );

	m_btnSinglePlayer->setGeometry(
		QWidget::width() / 2 - m_btnSinglePlayer->width() / 2,
		QWidget::height() - m_btnSinglePlayer->height() / 2 - 150, 250, 40);
	m_btnTwoPlayer->setGeometry(
		QWidget::width() / 2 - m_btnTwoPlayer->width() / 2,
		QWidget::height() - m_btnTwoPlayer->height() / 2 - 100, 250, 40 );
	m_btnExit->setGeometry( QWidget::width() / 2 - m_btnExit->width() / 2,
		QWidget::height() - m_btnExit->height() / 2 - 50, 250, 40 );
}<|endoftext|>


<commit_before>void runBatch() {
  TStopwatch timer;
  timer.Start();

  printf("*** Connect to AliEn ***\n");
  TGrid::Connect("alien://");
  gSystem->Load("libProofPlayer.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libTree.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libXMLIO.so");
  gSystem->Load("libPhysics.so");

  int runFemto = 1;
  int runSpectraProtons = 1;
  int runSpectraV0 = 1;
  int runFlow = 1;
  int runResonances = 1;
  int runEvChar = 1;
  int runKink = 1;
  int runUnicor = 1;
  int runFMDanalysis = 1;

  //____________________________________________________//
  //_____________Setting up STEERBase.par_______________//
  //____________________________________________________//
  //  setupPar("STEERBase");
  gSystem->Load("libSTEERBase.so");

  //____________________________________________________//
  //_____________Setting up ESD.par_____________________//
  //____________________________________________________//
  //  setupPar("ESD");
  gSystem->Load("libVMC.so");
  gSystem->Load("libESD.so");

  //____________________________________________________//
  //_____________Setting up AOD.par_____________________//
  //____________________________________________________//
  //  setupPar("AOD");
  gSystem->Load("libAOD.so");

  //_________________________________________________________//
  //_____________Setting up ANALYSIS.par_____________________//
  //_________________________________________________________//
  //  setupPar("ANALYSIS");
  gSystem->Load("libANALYSIS.so");

  //_________________________________________________________//
  //_____________Setting up ANALYSISalice.par________________//
  //_________________________________________________________//
  //  setupPar("ANALYSISalice");
  gSystem->Load("libANALYSISalice.so");

  //____________________________________________________//
  //_____________Setting up CORRFW library______________//
  //____________________________________________________//
  //  setupPar("CORRFW");
  gSystem->Load("libCORRFW.so");

  //____________________________________________________//
  //_____________Setting up PWG2AOD.par_________________//
  //____________________________________________________//
  setupPar("PWG2AOD");
  gSystem->Load("libPWG2AOD.so");

  if (runFemto) {
    //____________________________________________________//
    //_____________Setting up PWG2femtoscopy.par__________//
    //____________________________________________________//
    setupPar("PWG2femtoscopy");
    gSystem->Load("libPWG2femtoscopy.so");

    //____________________________________________________//
    //_____________Setting up PWG2femtoscopyUser.par______//
    //____________________________________________________//
    setupPar("PWG2femtoscopyUser");
    gSystem->Load("libPWG2femtoscopyUser.so");
  }

  if (runSpectraProtons) {
    //____________________________________________________//
    //_____________Setting up PWG2spectra library ________//
    //____________________________________________________//
    gSystem->Load("libPWG2spectra.so");
  }

  if (runSpectraV0) {
    //____________________________________________________//
    //_____________Setting up PWG2spectra library ________//
    //____________________________________________________//
    gSystem->Load("libPWG2spectra.so");
  }

  if (runFlow) {
    //____________________________________________________//
    //_____________Setting up PWG2flowCommon.par__________//
    //____________________________________________________//
    setupPar("PWG2flowCommon");
    gSystem->Load("libPWG2flowCommon.so");

    //____________________________________________________//
    //_____________Setting up PWG2flowTasks.par___________//
    //____________________________________________________//
    setupPar("PWG2flowTasks");
    gSystem->Load("libPWG2flowTasks.so");
  }

  if (runResonances) {
    //____________________________________________________//
    //_____________Setting up PWG2resonances.par__________//
    //____________________________________________________//
    setupPar("PWG2resonances");
    gSystem->Load("libPWG2resonances.so");
  }

  if (runEvChar) {
    //____________________________________________________//
    //_____________Setting up PWG2evchar library__________//
    //____________________________________________________//
    setupPar("PWG2evchar");
    gSystem->Load("libPWG2evchar.so");
  }

  if (runKink) {
    //____________________________________________________//
    //_____________Setting up PWG2evchar library__________//
    //____________________________________________________//
    setupPar("PWG2kink");
    gSystem->Load("libPWG2kink.so");
  }

  if (runUnicor) {
    //____________________________________________________//
    //_____________Setting up PWG2evchar library__________//
    //____________________________________________________//
    setupPar("PWG2unicor");
    gSystem->Load("libPWG2unicor.so");
  }

  if (runFMDanalysis) {
    //____________________________________________________//
    //_____________Setting up PWG2evchar library__________//
    //____________________________________________________//
    setupPar("FMDanalysis");
    gSystem->Load("libFMDanalysis.so");
  }

  //ANALYSIS PART
  const char *collectionfile="wn.xml";
  //____________________________________________//
  //Usage of event tags
  AliTagAnalysis *analysis = new AliTagAnalysis();
  TChain *chain = 0x0;
  chain = analysis->GetChainFromCollection(collectionfile,"esdTree");

  //  const char *collectionfile="../../LHC09a4/esd.LHC09a4.81305.mini.list";
  //  gROOT->LoadMacro("CreateESDChain.C");
  //  chain = CreateESDChain(collectionfile);

  //____________________________________________//
  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
  AliESDInputHandler* esdH = new AliESDInputHandler;
  //  esdH->SetInactiveBranches("FMD CaloCluster");
  mgr->SetInputEventHandler(esdH);

  AliMCEventHandler *mcH = new AliMCEventHandler;
  mgr->SetMCtruthEventHandler(mcH);
  if (runFemto) {
    //____________________________________________//
    // 1st task - FEMTOSCOPY

    gROOT->LoadMacro("AddTaskFemto.C");
    AliAnalysisTaskFemto *taskfemto = AddTaskFemto();
  }

  if (runSpectraProtons) {
    //____________________________________________//
    // 2nd task - SPECTRA protons

    gROOT->LoadMacro("AddTaskProtons.C");
    AliAnalysisTaskProtons *taskprotons = AddTaskProtons();
  }

  if (runFlow) {
    //____________________________________________//
    // 3rd task - FLOW

    // Flow analysis method can be:(set to kTRUE or kFALSE)
    Bool_t SP     = kTRUE;
    Bool_t LYZ1   = kTRUE;
    Bool_t LYZ2   = kFALSE;
    Bool_t LYZEP  = kFALSE;
    Bool_t GFC    = kFALSE;
    Bool_t QC     = kTRUE;
    Bool_t FQD    = kTRUE;
    Bool_t MCEP   = kTRUE;

    Bool_t METHODS[] = {SP,LYZ1,LYZ2,LYZEP,GFC,QC,FQD,MCEP};

    // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
    const TString type = "ESD";

    // Boolean to fill/not fill the QA histograms
    Bool_t QA = kTRUE;

    // Boolean to use/not use weights for the Q vector
    Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)

    gROOT->LoadMacro("AddTaskFlow.C");
    AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
  }

  if (runResonances) {
    //____________________________________________//
    // 4th task - RESONANCES

    int useMC = 1;

    gROOT->LoadMacro("AddAnalysisTaskRsn.C");
    //    AliAnalysisTaskFemto *taskfemto = AddTaskFemto();
    AddAnalysisTaskRsn(AliLog::kInfo, "rsn.root", useMC);
  }

  if (runEvChar) {
    //____________________________________________//
    // 5th task - EVENT CHARACTERIZARION

    gROOT->LoadMacro("AddTaskSPDdNdEta.C");
    AliAnalysisTaskSPDdNdEta *taskspddndeta = AddTaskSPDdNdEta();
  }

  if (runSpectraV0) {
    //____________________________________________//
    // 6th, 7th, 8th tasks - SPECTRA V0

    // cascades
    gROOT->LoadMacro("AddTaskCheckCascade.C");
    AliAnalysisTaskCheckCascade *taskcheckcascade = AddTaskCheckCascade(0);

    // v0's
    gROOT->LoadMacro("AddTaskCheckV0.C");
    AliAnalysisTaskCheckV0 *taskcheckV0 = AddTaskCheckV0();

    // strangeness
    gROOT->LoadMacro("AddTaskStrange.C");
    AliAnalysisTaskStrange *taskstrange = AddTaskStrange();
  }

  if (runKink) {
    //____________________________________________//
    // 9th, 10th, 11th tasks - KINK
    gROOT->LoadMacro("AddTaskKink.C");
    AliAnalysisKinkESDMC *taskkink = AddTaskKink();

    gROOT->LoadMacro("AddTaskKinkResonance.C");
    AliAnalysisTaskKinkResonance *taskkinkres = AddTaskKinkResonance();

    gROOT->LoadMacro("AddTaskKinkResonanceLikeSign.C");
    AliResonanceKinkLikeSign *taskkinklikesign = AddTaskKinkResonanceLikeSign();
  }

  if (runUnicor) {
    //____________________________________________//
    // 12th task - UNICOR
    gROOT->LoadMacro("AddTaskUnicor.C");
    AliAnalysisTaskUnicor *taskunicor = AddTaskUnicor();
  }

  if (runFMDanalysis) {
    //____________________________________________//
    // 13th task - FMD
    gROOT->LoadMacro("AddTaskFMD.C");
    AliFMDAnalysisTaskSE *taskfmd = AddTaskFMD();
  }

  //____________________________________________//
  // Running the train

  if (!mgr->InitAnalysis()) return;
  mgr->PrintStatus();
  mgr->StartAnalysis("local",chain);

  timer.Stop();
  timer.Print();
}

Int_t setupPar(const char* pararchivename) {
  ///////////////////
  // Setup PAR File//
  ///////////////////
  if (pararchivename) {
    char processline[1024];
    sprintf(processline,".! tar xvzf %s.par",pararchivename);
    gROOT->ProcessLine(processline);
    const char* ocwd = gSystem->WorkingDirectory();
    gSystem->ChangeDirectory(pararchivename);

    // check for BUILD.sh and execute
    if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
      printf("*******************************\n");
      printf("*** Building PAR archive    ***\n");
      printf("*******************************\n");

      if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
        Error("runProcess","Cannot Build the PAR Archive! - Abort!");
        return -1;
      }
    }
    // check for SETUP.C and execute
    if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
      printf("*******************************\n");
      printf("*** Setup PAR archive       ***\n");
      printf("*******************************\n");
      gROOT->Macro("PROOF-INF/SETUP.C");
    }

    gSystem->ChangeDirectory("../");
  }

  return 1;
}
<commit_msg>Update the runBatch.C macro to the most recent code and new wagons<commit_after>void runBatch() {
  TStopwatch timer;
  timer.Start();

  printf("*** Connect to AliEn ***\n");
  TGrid::Connect("alien://");
  gSystem->Load("libProofPlayer.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libTree.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libXMLIO.so");
  gSystem->Load("libPhysics.so");

  int runFemto = 1;
  int runSpectraProtons = 1;
  int runSpectraV0 = 1;
  int runFlow = 1;
  int runResonances = 1;
  int runEvChar = 1;
  int runKink = 1;
  int runUnicor = 1;
  int runFMDanalysis = 0;
  int runLRC = 1;

  int useGeneralParFiles = 0;
  int usePWG2ParFiles = 0;

  //____________________________________________________//
  //_____________Setting up STEERBase.par_______________//
  //____________________________________________________//
  if (useGeneralParFiles) {
    setupPar("STEERBase");
  }
  gSystem->Load("libSTEERBase.so");

  //____________________________________________________//
  //_____________Setting up ESD.par_____________________//
  //____________________________________________________//
  if (useGeneralParFiles) {
    setupPar("ESD");
  }
  gSystem->Load("libVMC.so");
  gSystem->Load("libESD.so");

  //____________________________________________________//
  //_____________Setting up AOD.par_____________________//
  //____________________________________________________//
  if (useGeneralParFiles) {
    setupPar("AOD");
  }
  gSystem->Load("libAOD.so");

  //_________________________________________________________//
  //_____________Setting up ANALYSIS.par_____________________//
  //_________________________________________________________//
  if (useGeneralParFiles) {
    setupPar("ANALYSIS");
  }
  gSystem->Load("libANALYSIS.so");

  //_________________________________________________________//
  //_____________Setting up ANALYSISalice.par________________//
  //_________________________________________________________//
  if (useGeneralParFiles) {
    setupPar("ANALYSISalice");
  }
  gSystem->Load("libANALYSISalice.so");

  //____________________________________________________//
  //_____________Setting up CORRFW library______________//
  //____________________________________________________//
  if (useGeneralParFiles) {
    setupPar("CORRFW");
  }
  gSystem->Load("libCORRFW.so");

  //____________________________________________________//
  //_____________Setting up PWG2AOD.par_________________//
  //____________________________________________________//
  if (usePWG2ParFiles) {
    setupPar("PWG2AOD");
  }
  gSystem->Load("libPWG2AOD.so");

  if (runFemto) {
    //____________________________________________________//
    //_____________Setting up PWG2femtoscopy.par__________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2femtoscopy");
    }
    gSystem->Load("libPWG2femtoscopy.so");

    //____________________________________________________//
    //_____________Setting up PWG2femtoscopyUser.par______//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2femtoscopyUser");
    }
    gSystem->Load("libPWG2femtoscopyUser.so");
  }

  if (runSpectraProtons) {
    //____________________________________________________//
    //_____________Setting up PWG2spectra library ________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2spectra");
    }
    gSystem->Load("libPWG2spectra.so");
  }

  if (runSpectraV0) {
    //____________________________________________________//
    //_____________Setting up PWG2spectra library ________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2spectra");
    }
    gSystem->Load("libPWG2spectra.so");
  }

  if (runFlow) {
    //____________________________________________________//
    //_____________Setting up PWG2flowCommon.par__________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2flowCommon");
    }
    gSystem->Load("libPWG2flowCommon.so");

    //____________________________________________________//
    //_____________Setting up PWG2flowTasks.par___________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2flowTasks");
    }
    gSystem->Load("libPWG2flowTasks.so");
  }

  if (runResonances) {
    //____________________________________________________//
    //_____________Setting up PWG2resonances.par__________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2resonances");
    }
    gSystem->Load("libPWG2resonances.so");
  }

  if (runEvChar) {
    //____________________________________________________//
    //_____________Setting up PWG2evchar library__________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2evchar");
    }
    gSystem->Load("libPWG2evchar.so");
  }

  if (runKink) {
    //____________________________________________________//
    //_____________Setting up PWG2kink library____________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2kink");
    }
    gSystem->Load("libPWG2kink.so");
  }

  if (runUnicor) {
    //____________________________________________________//
    //_____________Setting up PWG2unicor library__________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2unicor");
    }
    gSystem->Load("libPWG2unicor.so");
  }

  if (runFMDanalysis) {
    //____________________________________________________//
    //_____________Setting up FMD analysis library________//
    //____________________________________________________//
    //    setupPar("FMDanalysis");
    gSystem->Load("libFMDanalysis.so");
  }

  if (runLRC) {
    //____________________________________________________//
    //_____________Setting up PWG2ebye library____________//
    //____________________________________________________//
    if (usePWG2ParFiles) {
      setupPar("PWG2ebye");
    }
    gSystem->Load("libPWG2ebye.so");
  }

  //ANALYSIS PART
  const char *collectionfile="wn.xml";
  //____________________________________________//
  //Usage of event tags
  AliTagAnalysis *analysis = new AliTagAnalysis();
  TChain *chain = 0x0;
  chain = analysis->GetChainFromCollection(collectionfile,"esdTree");

  //  const char *collectionfile="../../LHC09a4/esd.LHC09a4.81305.mini.list";
  //  gROOT->LoadMacro("CreateESDChain.C");
  //  chain = CreateESDChain(collectionfile);

  //____________________________________________//
  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
  AliESDInputHandler* esdH = new AliESDInputHandler;
  //  esdH->SetInactiveBranches("FMD CaloCluster");
  mgr->SetInputEventHandler(esdH);

  AliMCEventHandler *mcH = new AliMCEventHandler;
  mgr->SetMCtruthEventHandler(mcH);
  if (runFemto) {
    //____________________________________________//
    // 1st task - FEMTOSCOPY

    gROOT->LoadMacro("AddTaskFemto.C");
    AliAnalysisTaskFemto *taskfemto = AddTaskFemto();
  }

  if (runSpectraProtons) {
    //____________________________________________//
    // 2nd task - SPECTRA protons

    gROOT->LoadMacro("AddTaskProtons.C");
    AliAnalysisTaskProtons *taskprotons = AddTaskProtons();
  }

  if (runFlow) {
    //____________________________________________//
    // 3rd task - FLOW

    // Flow analysis method can be:(set to kTRUE or kFALSE)
    Bool_t SP       = kTRUE;
    Bool_t LYZ1SUM  = kTRUE;
    Bool_t LYZ1PROD = kTRUE;
    Bool_t LYZ2SUM  = kFALSE;
    Bool_t LYZ2PROD = kFALSE;
    Bool_t LYZEP    = kFALSE;
    Bool_t GFC      = kTRUE;
    Bool_t QC       = kTRUE;
    Bool_t FQD      = kTRUE;
    Bool_t MCEP     = kTRUE; //not for pp

    Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP};

    // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
    const TString type = "ESD";

    // Boolean to fill/not fill the QA histograms
    Bool_t QA = kTRUE;

    // Boolean to use/not use weights for the Q vector
    Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)

    gROOT->LoadMacro("AddTaskFlow.C");
    AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
  }

  if (runResonances) {
    //____________________________________________//
    // 4th task - RESONANCES

    int useMC = 1;

    gROOT->LoadMacro("AddAnalysisTaskRsn.C");
    //    AliAnalysisTaskFemto *taskfemto = AddTaskFemto();
    //    AddAnalysisTaskRsn(AliLog::kInfo, kFALSE, "rsn.root", useMC);
    AddAnalysisTaskRsn();
  }

  if (runEvChar) {
    //____________________________________________//
    // 5th task - EVENT CHARACTERIZARION

    gROOT->LoadMacro("AddTaskSPDdNdEta.C");
    AliAnalysisTaskSPDdNdEta *taskspddndeta = AddTaskSPDdNdEta();
  }

  if (runSpectraV0) {
    //____________________________________________//
    // 6th, 7th, 8th tasks - SPECTRA V0

    // cascades
    gROOT->LoadMacro("AddTaskCheckCascade.C");
    AliAnalysisTaskCheckCascade *taskcheckcascade = AddTaskCheckCascade(0);

    // v0's
    gROOT->LoadMacro("AddTaskCheckV0.C");
    AliAnalysisTaskCheckV0 *taskcheckV0 = AddTaskCheckV0();

    // strangeness
    gROOT->LoadMacro("AddTaskStrange.C");
    AliAnalysisTaskStrange *taskstrange = AddTaskStrange();
  }

  if (runKink) {
    //____________________________________________//
    // 9th, 10th, 11th tasks - KINK
    gROOT->LoadMacro("AddTaskKink.C");
    AliAnalysisKinkESDMC *taskkink = AddTaskKink();

    gROOT->LoadMacro("AddTaskKinkResonance.C");
    AliAnalysisTaskKinkResonance *taskkinkres = AddTaskKinkResonance();

    gROOT->LoadMacro("AddTaskKinkResonanceLikeSign.C");
    AliResonanceKinkLikeSign *taskkinklikesign = AddTaskKinkResonanceLikeSign();
  }

  if (runUnicor) {
    //____________________________________________//
    // 12th task - UNICOR
    gROOT->LoadMacro("AddTaskUnicor.C");
    AliAnalysisTaskUnicor *taskunicor = AddTaskUnicor();
  }

  if (runFMDanalysis) {
    //____________________________________________//
    // 13th task - FMD
    gROOT->LoadMacro("AddTaskFMD.C");
    AliFMDAnalysisTaskSE *taskfmd = AddTaskFMD();
  }

  if (runLRC) {
    //____________________________________________//
    // 13th task - FMD
    gROOT->LoadMacro("AddTaskLRC.C");
    //    AliFMDAnalysisTaskSE *taskfmd = AddTaskFMD();
    TList *lrcasks = AddLRCTaskSet();
  }

  //____________________________________________//
  // Running the train

  if (!mgr->InitAnalysis()) return;
  mgr->PrintStatus();
  mgr->StartAnalysis("local",chain);

  timer.Stop();
  timer.Print();
}

Int_t setupPar(const char* pararchivename) {
  ///////////////////
  // Setup PAR File//
  ///////////////////
  if (pararchivename) {
    char processline[1024];
    sprintf(processline,".! tar xvzf %s.par",pararchivename);
    gROOT->ProcessLine(processline);
    const char* ocwd = gSystem->WorkingDirectory();
    gSystem->ChangeDirectory(pararchivename);

    // check for BUILD.sh and execute
    if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
      printf("*******************************\n");
      printf("*** Building PAR archive    ***\n");
      printf("*******************************\n");

      if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
        Error("runProcess","Cannot Build the PAR Archive! - Abort!");
        return -1;
      }
    }
    // check for SETUP.C and execute
    if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
      printf("*******************************\n");
      printf("*** Setup PAR archive       ***\n");
      printf("*******************************\n");
      gROOT->Macro("PROOF-INF/SETUP.C");
    }

    gSystem->ChangeDirectory("../");
  }

  return 1;
}
<|endoftext|>


<commit_before>#include "ofApp.h"
#include "ofxIconMaker.h"

//--------------------------------------------------------------
ofxIconMaker* icon1;

void ofApp::setup(){

	//you can download "https://design.google.com/icons/"
	//and extract to bin/icon folder.

	//create icon width icon folder name

	icon1 = new ofxIconMaker("ic_account_circle_white_24dp" );

	//choose resolustion X1 , X2 , defalut X3
	//icon1 = new ofxIconMaker("ic_account_circle_white_24dp", ofxIconMaker::X1);
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){
	ofSetColor(ofColor::blue);
	icon1->getImage().draw(0, 0);
	icon1->getImage().draw(0, 100, 200, 200);
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){

}
<commit_msg>Update ofApp.cpp<commit_after>#include "ofApp.h"
#include "ofxIconMaker.h"

//--------------------------------------------------------------
ofxIconMaker* icon1;

void ofApp::setup(){

	//you can download "https://design.google.com/icons/"
	//and extract to bin/data/icon folder.

	//create icon width icon folder name

	icon1 = new ofxIconMaker("ic_account_circle_white_24dp" );

	//choose resolustion X1 , X2 , defalut X3
	//icon1 = new ofxIconMaker("ic_account_circle_white_24dp", ofxIconMaker::X1);
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){
	ofSetColor(ofColor::blue);
	icon1->getImage().draw(0, 0);
	icon1->getImage().draw(0, 100, 200, 200);
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){

}
<|endoftext|>