Example #1
0
static void window_send_letter_window_letter(void**state){
	OS_t * new_OS = OS_new("Jupiter");
	OS_t * new_OS2 = OS_new("Saturn");
	window_t* pwindow1 = OS_window_new(new_OS, "Callisto", "i am test");
	window_t* pwindow2 = OS_window_new(new_OS, "Themisto", "i am test");
	window_t* pwindow3 = OS_window_new(new_OS2, "Deniz", "i am lucky one");
	assert_string_equal(window_send_letter(new_OS, pwindow1, pwindow2), "Your letter succesfuly sent!");
	assert_string_equal(window_send_letter(new_OS2, pwindow1, pwindow3), "You can`t send letters to windows of other operstion system!");
	window_free(pwindow1);
	window_free(pwindow2);
	window_free(pwindow3);
	OS_free(new_OS);
	OS_free(new_OS2);
}
Example #2
0
static void window_createNew_name_window(void** state){
	OS_t * new_OS = OS_new("Jupiter");
	window_t* pwindow = OS_window_new(new_OS, "Callisto", "i am test");
	assert_int_equal(window_get_amount_of_recivedletters(pwindow), 0);
	window_free(pwindow);
	OS_free(new_OS);
}
Example #3
0
int FS460_image_set_start_write(const void *p_image_data, unsigned long length)
{
    int err;
    void *p_buffer;

    if (!p_image_data)
        return FS460_ERR_INVALID_PARAMETER;

    // allocate a buffer for length and data bytes
    p_buffer = OS_alloc(sizeof(unsigned long) + length);
    if (!p_buffer)
        return FS460_ERR_INSUFFICIENT_MEMORY;

    // store length and data bytes
    *(unsigned long *)p_buffer = length;
    OS_memcpy(((unsigned long *)p_buffer) + 1, p_image_data, length);

    // call driver
    err = send_io_code_to_driver(IOC_IMAGE_SET_START_WRITE, p_buffer, sizeof(unsigned long) + length);

    // free buffer
    OS_free(p_buffer);

    return err;
}
Example #4
0
static void OS_get_window_from_listOFwindow_void_window(void **state){
	OS_t * new_OS = OS_create("Jupiter");
	window_t * pwindow = window_createNew(new_OS, "TESTwindow", "test");
	assert_ptr_equal(OS_get_window_from_listOFwindow(new_OS), pwindow);
	window_free(pwindow);
	OS_free(new_OS);
}
Example #5
0
static void window_getName_window_name(void** state){
	OS_t * new_OS = OS_new("Jupiter");
	window_t* pwindow = OS_window_new(new_OS, "Callisto", "i am test");
	assert_string_equal(window_getName(pwindow), "Callisto");
	window_free(pwindow);
	OS_free(new_OS);
}
Example #6
0
/*****************************************************************************
 * Function - DeAlloc
 * DESCRIPTION: Deallocates all the memory allocated by Alloc and AllocBlock
 *
 * Return:      The number of bytes deallocated
 *
 *****************************************************************************/
int TestAlloc::DeAlloc()
{
  BLOCK* current_block = mFirstBlock;
  int memory_deallocated = 0;

  while (current_block != NULL)
  {
    char* del_block = (char*)current_block;
    memory_deallocated += current_block->memory_used;
    current_block = current_block->next_block;
    #if defined  TEST_USING_NEW_DELETE
    delete [] del_block;
    #elif defined TEST_USING_C_MALLOC_FREE
    free(del_block);
    #elif defined TEST_USING_OS_MALLOC_FREE
    OS_free(del_block);
    #endif
  }

  mAllocated = 0;
  mFirstBlock = NULL;
  mLastBlock = NULL;

  return memory_deallocated;
}
Example #7
0
static void window_start_window_void(void** state){
	OS_t * new_OS = OS_new("Jupiter");
	window_t* pwindow = OS_window_new(new_OS, "Callisto", "i am test");
	window_start(new_OS, pwindow);
	assert_int_equal(OS_get_amountOFworking_window(new_OS), 1);
	window_free(pwindow);
	OS_free(new_OS);
}
Example #8
0
static void OS_create__hasName__returnsOSstruct(void **state){
	OS_t * new_OS = OS_new("Jupiter");
	char char1[] = { "Jupiter" };
	const char* pointchar1 = &char1;
	const char* pointchar2 = OS_getName(new_OS);
	assert_string_equal(pointchar1, pointchar2);
	OS_free(new_OS);
}
Example #9
0
static void OS_inc_amountOFworking_window__amountOFworking_window__returns_inc_amountOFworking_window(void **state){
	OS_t * new_OS = OS_new("Jupiter");
	window_t * pwindow = OS_window_new(new_OS, "TESTwindow", "test");
	window_start(new_OS, pwindow);
	assert_int_equal(OS_get_amountOFworking_window(new_OS), 1);
	window_free(pwindow);
	OS_free(new_OS);
}
Example #10
0
static void window_free_pwindow_void(void**state){
	OS_t * new_OS = OS_new("Jupiter");
	window_t* pwindow1 = OS_window_new(new_OS, "Callisto", "i am test");
	assert_int_equal(window_free(window_free(pwindow1)), NULL);
	window_t* pwindow2 = OS_window_new(new_OS, "Themisto", "i am test");
	assert_int_equal(window_free(pwindow2), NULL);
	OS_free(new_OS);
}
Example #11
0
static void OS_set_new_window_in_listOFwindow_new_window_listOFwindow(void **state){
	OS_t * new_OS = OS_create("Jupiter");
	window_t * pwindow1 = window_createNew(new_OS, "TESTwindow", "test");
	window_t * pwindow2 = OS_get_window_from_listOFwindow(new_OS);
	assert_ptr_equal(pwindow1, pwindow2);
	window_free(pwindow1);
	OS_free(new_OS);
}
Example #12
0
static void window_send_letter_window_letter(void**state){
	OS_t * new_OS = OS_create("Jupiter");
	window_t* pwindow1 = window_createNew(new_OS, "Callisto", "i am test");
	window_t* pwindow2 = window_createNew(new_OS, "Themisto", "i am test");
	assert_string_equal(window_send_letter(new_OS, pwindow1, pwindow2), "i am test");
	window_free(pwindow1);
	window_free(pwindow2);
	OS_free(new_OS);
}
Example #13
0
static void window_getStatus_window_status(void** state){
	OS_t * new_OS = OS_new("Jupiter");
	window_t* pwindow = OS_window_new(new_OS, "Callisto", "i am test");
	window_start(new_OS, pwindow);
	assert_int_equal(window_getStatus(pwindow), working);
	window_end(new_OS, pwindow);
	assert_int_equal(window_getStatus(pwindow), non_working);
	window_free(pwindow);
	OS_free(new_OS);
}
Example #14
0
static void window_get_amount_of_recivedletters_window_amountOfrecivedLetters(void** state){
	OS_t * new_OS = OS_new("Jupiter");
	window_t* pwindow1 = OS_window_new(new_OS, "Callisto", "i am test");
	window_t* pwindow2 = OS_window_new(new_OS, "Themisto", "i am test");
	window_send_letter(new_OS, pwindow1, pwindow2);
	assert_int_equal(window_get_amount_of_recivedletters(pwindow2), 1);
	window_free(pwindow1);
	window_free(pwindow2);
	OS_free(new_OS);
}
Example #15
0
void main(int argc, char *argv[]){
	if (strcmp(argv[1],"tests")==0) 
		{
		module_runTests();
	}
	else if (strcmp(argv[1], "modules") == 0){
	OS_t* Linux = OS_new("Linux");//1.0
	OS_t* Windows = OS_new("Windows");//2.0
	OS_window_new(Linux, "Internet","HELLO");//1.2
	puts("listOfWindows(Linux)");
	
	OS_print_listOfWindows(Linux);
	OS_deleteWindow(Linux, 2);
	puts("listOfWindows(Linux) after deleting window(2)");

	OS_print_listOfWindows(Linux);
	OS_window_new(Windows, "Camomiles","LOVE");//2.2
	OS_window_new(Windows, "Roses","SAD");//2.3
	puts("listOfWindows(Windows)");
	OS_print_listOfWindows(Windows);
	window_start(Windows, 2);
	window_start(Windows, 3);
	puts("listOFworking_windows(Windows)");
	OS_print_listOFworking_windows(Windows);
	window_end(Windows,2);
	puts("listOFworking_windows(Windows)");
	OS_print_listOFworking_windows(Windows);
	window_send_letter(Windows, 2, 3);
	window_send_letter(Windows, 2, 3);
	window_send_letter(Windows, 3, 2);
	puts("listOFrecivedLetters(Roses)");
	window_print_listOfrecievedLetters(Windows,3);
	puts("listOFrecived_windows(Camomailes)");
	window_print_listOfrecievedLetters(Windows,2);
	window_free(Windows,2);
	window_free(Windows,3);
	OS_free(Linux);
	OS_free(Windows);
	getchar();
	}
}
void osFreeMem(void *p)
{
   //Make sure the pointer is valid
   if(p != NULL)
   {
      //Debug message
      TRACE_DEBUG("Freeing memory at 0x%08" PRIXPTR "\r\n", (uintptr_t) p);

      //Free memory block
      OS_free(p);
   }
}
Example #17
0
void
OS2_close_std_tqueue (tqueue_t * tqueue)
{
  OS2_close_event_semaphore (STD_TQUEUE_EVENT (tqueue));
  OS2_close_mutex_semaphore (STD_TQUEUE_MUTEX (tqueue));
  while (1)
    {
      msg_t * msg = (OS2_msg_fifo_remove (STD_TQUEUE_FIFO (tqueue)));
      if (msg == 0)
	break;
      OS2_destroy_message (msg);
    }
  OS_free (tqueue);
}
Example #18
0
void
OS2_close_std_tqueue (tqueue_t * tqueue)
{
  while (1)
    {
      msg_t * msg = (read_std_tqueue_1 (tqueue, 0));
      if (msg == 0)
	break;
      OS2_destroy_message (msg);
    }
  OS2_close_queue (STD_TQUEUE_FIFO (tqueue));
  OS2_close_event_semaphore (STD_TQUEUE_EVENT (tqueue));
  OS_free (tqueue);
}
Example #19
0
void *
OS2_realloc_noerror (void * ptr, unsigned long size)
{
  unsigned long osize = ((guarantee_valid_malloc_pointer (ptr)) -> size);
  if (osize == size)
    return (ptr);
  {
    void * result = (OS2_malloc_noerror (size));
    if (result != 0)
      {
	char * scan1 = ptr;
	char * end1 = (scan1 + ((osize < size) ? osize : size));
	char * scan2 = result;
	while (scan1 < end1)
	  (*scan2++) = (*scan1++);
	OS_free (ptr);
      }
    return (result);
  }
}
Example #20
0
const char *
OS_get_host_name (void)
{
  unsigned int name_length = 128;
  char * name = (OS_malloc (name_length));
  while (1)
    {
      if ((gethostname (name, name_length)) != SOCKET_ERROR)
	break;
      {
	DWORD code = (WSAGetLastError ());
	if (code != WSAEFAULT)
	  {
	    OS_free (name);
	    NT_error_api_call (code, apicall_gethostname);
	  }
      }
      name_length *= 2;
      name = (OS_realloc (name, name_length));
    }
  return (OS_realloc (name, ((strlen (name)) + 1)));
}
Example #21
0
static void OS_get_amountOFwindow_OS_ammount(void **state){
	OS_t * new_OS = OS_new("Jupiter");
	assert_int_equal(OS_get_amountOFwindow(new_OS), 1);
	OS_free(new_OS);
}
Example #22
0
/*----------------------------------------------------------------------*
                              _rtp_free
 *----------------------------------------------------------------------*/
void _rtp_free (void * ptr)
{
    OS_free (ptr);
}
Example #23
0
void
OS2_destroy_msg_fifo (void * fp)
{
  OS_free (((msg_fifo_t *) fp) -> buffer);
  OS_free (fp);
}
Example #24
0
void
OS2_destroy_message (msg_t * message)
{
  OS_free (message);
}
Example #25
0
static void OS_free_pOS_void(void**state){
	OS_t * new_OS = OS_new("Jupiter");
	assert_int_equal(OS_free(OS_free(new_OS)), 0);
	OS_t * new_OS1 = OS_new("Mars");
	assert_int_equal(OS_free(new_OS1), 0);
}
Example #26
0
static void OS_getName_OS_name(void **state){
	OS_t * new_OS = OS_new("Jupiter");
	assert_string_equal(OS_getName(new_OS), "Jupiter");
	OS_free(new_OS);
}
Example #27
0
static void OS_inc_amountOFwindow__amountOFwindow__returns_inc_amountOFwindow(void **state){
	OS_t * new_OS = OS_create("Jupiter");
	assert_int_equal(OS_get_amountOFwindow(new_OS), 1);
	OS_free(new_OS);
}