Skip to content
Snippets Groups Projects
Select Git revision
  • ec79aabdb9a27f16b922f0e8a7fcf30eb5462d2a
  • devel default
  • wenpeng-hot-fix
  • wenpeng-0905-mem
  • lk_debug_dialogs
  • asterisk_rdkb
  • lk_forking_revert
  • lk_em_update_new_design
  • wenpeng-jul8
  • gyang-devel
  • gyang-devel1
  • wenpeng-jul9
  • asterisk_rdkb_ipv6
  • 16916_rdkb_merge
  • lk_disable_registrar
  • wenpeng-100rel-ippbx
  • fix_multiple_dns_lookup
  • dev_fxs_no_wb
  • fix_fallback
  • 14666_fxs_no_wideband_codec
  • fix_srv_records
  • fix_deadlock_in_bridge_peer_functions
  • 22.0.0-pre1
  • 21.4.2
  • 20.9.2
  • 18.24.2
  • certified-20.7-cert2
  • certified-18.9-cert11
  • 21.4.1
  • 20.9.1
  • 18.24.1
  • 21.4.0
  • 20.9.0
  • 18.24.0
  • certified-20.7-cert1
  • certified-18.9-cert10
  • 21.4.0-rc1
  • 20.9.0-rc1
  • 18.24.0-rc1
  • 21.3.1
  • 20.8.1
  • 18.23.1
42 results

test_json.c

Blame
  • test_json.c 54.41 KiB
    /*
     * Asterisk -- An open source telephony toolkit.
     *
     * Copyright (C) 2012 - 2013, Digium, Inc.
     *
     * David M. Lee, II <dlee@digium.com>
     *
     * See http://www.asterisk.org for more information about
     * the Asterisk project. Please do not directly contact
     * any of the maintainers of this project for assistance;
     * the project provides a web site, mailing lists and IRC
     * channels for your use.
     *
     * This program is free software, distributed under the terms of
     * the GNU General Public License Version 2. See the LICENSE file
     * at the top of the source tree.
     */
    
    /*!
     * \file \brief Test JSON API.
     *
     * While some of these tests are actually testing our JSON library wrapper, the bulk of
     * them are exploratory tests to determine what the behavior of the underlying JSON
     * library is. This also gives us a good indicator if that behavior changes between
     * Jansson revisions.
     *
     * \author\verbatim David M. Lee, II <dlee@digium.com> \endverbatim
     *
     * \ingroup tests
     */
    
    /*** MODULEINFO
    	<depend>TEST_FRAMEWORK</depend>
    	<support_level>core</support_level>
     ***/
    
    #include "asterisk.h"
    
    ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
    #include "asterisk/json.h"
    #include "asterisk/module.h"
    #include "asterisk/test.h"
    
    #include <stdio.h>
    #include <unistd.h>
    
    #define CATEGORY "/main/json/"
    
    /*!
     * Number of allocations from JSON library that have not yet been freed.
     */
    static size_t alloc_count;
    
    /*!@{*/
    /*!
     * JSON library has its own reference counting, so we'll provide our own allocators to
     * test that everything gets freed as expected.
     */
    static void *json_debug_malloc(size_t size)
    {
    	void *p = ast_json_malloc(size);
    	if (p) {
    		++alloc_count;
    	}
    	return p;
    }
    
    static void json_debug_free(void *p)
    {
    	if (p) {