pull/1774/head
Nate Bargmann 2025-06-22 07:04:07 -05:00
commit 1441ce1839
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: FB2C5130D55A8819
21 zmienionych plików z 1196 dodań i 521 usunięć

Wyświetl plik

@ -2,7 +2,7 @@ name: C/C++ CI
on:
push:
branches: [ master ]
branches: [ master, feature/* ]
pull_request:
branches: [ master ]
@ -21,6 +21,7 @@ jobs:
sudo apt install libusb-1.0-0-dev
sudo apt install libgpiod-dev
sudo apt install grep
sudo apt install python3-dev python3-pytest
- name: Install dependencies on macOS
if: runner.os == 'macOS'
run: |
@ -38,7 +39,11 @@ jobs:
- name: README Debug
run: grep README Makefile.am
- name: configure
run: ./configure
if: runner.os != 'macOS'
run: ./configure --with-python-binding
- name: configure on macOS
if: runner.os == 'macOS'
run: ./configure --without-python-binding
- name: make
run: make -j 4
- name: make check

Wyświetl plik

@ -285,6 +285,7 @@ Optional, but highly recommended:
* perl devel # h2xs
* tcl devel # tcltk-depends
* python devel # python-config
* pytest
* lua devel
* libxml2 devel # xml2-config --version
* libgd2 devel # gdlib-config --version (rigmatrix)
@ -440,6 +441,46 @@ as above and once the run is complete:
The resulting generated document in the 'latex' directory is 'refman.pdf'.
1.3.2 Automated tests
Automated tests are executed running:
make check
The makefiles run the simple tests with automake.
The make variable TESTS contains the tests to be run and the variables
check_PROGRAMS and check_SCRIPTS contain the executables needed to run the
tests that aren't built by make all.
For more information see the automake manual at
https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html
1.3.2.1 C tests
Tests written in C are available in the tests/ directory. They are run with:
make -C tests/ check
1.3.2.2 Python tests with pytest
Tests written in Python are available in the bindings/python directory if
Hamlib is configured to build the Python bindings and if pytest is installed,
eg.:
./configure --with-python-binding --enable-pytest
They are run with:
make -C bindings/ check
The Python scripts consist in handwritten tests, meant to test realistic use
cases, and autogenerated tests, meant to detect unwanted changes in the
bindings. When a public symbol is added to the bindings or removed, the
autogenerated tests must be updated:
make -C bindings/ generate-pytests
and the handwritten tests should be updated to reflect the change.
1.4. Feedback

Wyświetl plik

@ -9,7 +9,7 @@ AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/include -I$(top_srcdir)/bindings \
AM_CFLAGS = @AM_CPPFLAGS@ -fno-strict-aliasing
AM_CXXFLAGS = -O2
SWGFILES = hamlib.swg ignore.swg rig.swg rotator.swg amplifier.swg
SWGFILES = hamlib.swg ignore.swg rig.swg rotator.swg amplifier.swg macros.swg
SWGDEP = \
$(top_srcdir)/include/hamlib/rig.h \
@ -21,7 +21,13 @@ SWGDEP = \
$(SWGFILES)
EXTRA_DIST = $(SWGFILES) \
Makefile.PL perltest.pl tcltest.tcl.in pytest.py py3test.py \
Makefile.PL perltest.pl tcltest.tcl.in \
python/generate_tests.py \
python/test_Hamlib_Amp_class.py \
python/test_Hamlib_class.py \
python/test_Hamlib_Rig_class.py \
python/test_Hamlib_Rot_class.py \
python/test_startup.py \
luatest.lua README.python
exampledir = $(docdir)/examples
@ -95,16 +101,6 @@ pyexec_ltlib = _Hamlib.la
MOSTLYCLEANFILES += hamlibpy_wrap.c Hamlib.py *.pyc
BUILT_SOURCES += hamlibpy_wrap.c Hamlib.py
# Set by AM_CONDITIONAL in configure.ac
if PYVER_3
pytest = py3test.py
else !PYVER_3
pytest = pytest.py
endif
# PYVER_3
example_DATA += $(pytest)
nodist_pyexec_PYTHON = Hamlib.py
nodist__Hamlib_la_SOURCES = hamlibpy_wrap.c
@ -115,10 +111,18 @@ _Hamlib_la_LTLIBRARIES = $(pyexec_ltlib)
all-py: $(pyexec_ltlib)
check-py: all-py
check-py: all-py pytest-${enable_pytest}
generate-pytests: all-py
$(AM_V_at)PYTHONPATH=$(builddir):$(builddir)/.libs \
$(PYTHON) $(srcdir)/$(pytest) \
|| echo "Python test failed" 1>&2
$(PYTHON) "$(srcdir)/python/generate_tests.py" "$(srcdir)/python/"
pytest-yes:
$(AM_V_at)PYTHONPATH=$(builddir):$(builddir)/.libs \
$(PYTEST) --capture=no $(srcdir)/
pytest-no:
@echo "Skipping pytest run"
Hamlib.py: hamlibpy_wrap.c

Wyświetl plik

@ -19,6 +19,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
%{
#include <hamlib/amplifier.h>
%}
%immutable amp_caps::model_name;
%immutable amp_caps::mfg_name;
%immutable amp_caps::version;
%immutable amp_caps::copyright;
%include <hamlib/amplist.h>
%include <hamlib/amplifier.h>
%inline %{
@ -43,7 +54,7 @@ typedef struct Amp {
{ self->error_status = amp_##f(self->amp, _##t1##_1, _##t2##_2); }
#define AMPMETHOD3(f, t1, t2, t3) void f (t1 _##t1##_1, t2 _##t2##_2, t3 _##t3##_3) \
{ self->error_status = amp_##f(self->amp, _##t1##_1, _##t2##_2, t3 _##t3##_3); }
#define AMPMETHOD4(f, t1, t2, t3, t4) void f (t1 _##t1##_1, t2 _##t2##_3, t3 _##t3##_3, ##t4##_4) \
#define AMPMETHOD4(f, t1, t2, t3, t4) void f (t1 _##t1##_1, t2 _##t2##_3, t3 _##t3##_3, t4 ##t4##_4) \
{ self->error_status = amp_##f(self->amp, _##t1##_1, _##t2##_3, t3 _##t3##_3, ##t4##_4); }
%extend Amp {
@ -104,7 +115,7 @@ typedef struct Amp {
/*
* declare wrapper method with one output argument besides AMP*
*/
#define AMPMETHOD1VGET(f, t1) t1 f \
#define AMPMETHOD1GET(f, t1) t1 f () \
{ t1 _##t1; self->error_status = amp_##f(self->amp, &_##t1); return _##t1; }
@ -126,6 +137,8 @@ typedef struct Amp {
return s;
}
AMPMETHOD1GET(get_freq, freq_t)
const char * get_info(void) {
const char *s;
s = amp_get_info(self->amp);
@ -133,15 +146,22 @@ typedef struct Amp {
return s;
}
};
%{
AMPMETHOD1GET(get_powerstat, powerstat_t)
void Amp_get_freq(Amp *self, freq_t *freq)
PyObject * get_level(setting_t level)
{
self->error_status = amp_get_freq(self->amp, freq);
value_t val;
self->error_status = amp_get_level(self->amp, level, &val);
if (self->error_status != RIG_OK)
return Py_None;
if (AMP_LEVEL_IS_FLOAT(level))
return PyFloat_FromDouble(val.f);
else if (AMP_LEVEL_IS_STRING(level))
return PyUnicode_FromString(val.s);
return PyLong_FromLong(val.i);
}
void Amp_get_powerstat(Amp *self, powerstat_t *status)
{
self->error_status = amp_get_powerstat(self->amp, status);
}
%}
};

Wyświetl plik

@ -29,9 +29,6 @@
#include <hamlib/config.h>
#include <hamlib/rig.h>
#include <hamlib/rotator.h>
#include <hamlib/amplifier.h>
//mdblack98 -- Commented this out -- is anybody using the functions in misc.h?
//If so, then those functions should be moved to rig.h
//#include "misc.h"
@ -40,6 +37,17 @@
%}
/*
* symbols that shouldn't be changed
*/
%immutable clone_combo_get;
%immutable clone_combo_set;
%immutable confparams::dflt;
%immutable confparams::label;
%immutable confparams::name;
%immutable confparams::tooltip;
%immutable cs;
/*
* symbols that won't be wrapped
*/
@ -200,34 +208,8 @@
#endif
#endif
%immutable confparams::name;
%immutable confparams::label;
%immutable confparams::tooltip;
%immutable confparams::dflt;
%immutable cs;
%immutable rig_caps::model_name;
%immutable rig_caps::mfg_name;
%immutable rig_caps::version;
%immutable rig_caps::copyright;
%immutable hamlib_version2;
%immutable hamlib_copyright2;
%immutable clone_combo_set;
%immutable clone_combo_get;
%immutable rot_caps::model_name;
%immutable rot_caps::mfg_name;
%immutable rot_caps::version;
%immutable rot_caps::copyright;
%include <hamlib/rig_dll.h>
%include <hamlib/riglist.h>
%include <hamlib/rig.h>
%include <hamlib/rotlist.h>
%include <hamlib/rotator.h>
%inline {
typedef const char * const_char_string;
}

Wyświetl plik

@ -1,213 +1,103 @@
/* unsupported Hamlib's calls */
/* Unsupported Hamlib's methods, properties and constants */
/* useless macros */
%ignore _RIG_H;
%ignore _RIGLIST_H;
%ignore _ROTLIST_H;
%ignore _ROTATOR_H;
%ignore RIG_DUMMY;
%ignore RIG_BACKEND_DUMMY;
%ignore RIG_YAESU;
%ignore RIG_BACKEND_YAESU;
%ignore RIG_KENWOOD;
%ignore RIG_BACKEND_KENWOOD;
%ignore RIG_ICOM;
%ignore RIG_BACKEND_ICOM;
%ignore RIG_PCR;
%ignore RIG_BACKEND_PCR;
%ignore RIG_AOR;
%ignore RIG_BACKEND_AOR;
%ignore RIG_JRC;
%ignore RIG_BACKEND_JRC;
%ignore RIG_RADIOSHACK;
%ignore RIG_BACKEND_RADIOSHACK;
%ignore RIG_UNIDEN;
%ignore RIG_BACKEND_UNIDEN;
%ignore RIG_DRAKE;
%ignore RIG_BACKEND_DRAKE;
%ignore RIG_LOWE;
%ignore RIG_BACKEND_LOWE;
%ignore RIG_RACAL;
%ignore RIG_BACKEND_RACAL;
%ignore RIG_WJ;
%ignore RIG_BACKEND_WJ;
%ignore RIG_EK;
%ignore RIG_BACKEND_EK;
%ignore RIG_SKANTI;
%ignore RIG_BACKEND_SKANTI;
%ignore RIG_PRM80;
%ignore RIG_BACKEND_PRM80;
%ignore RIG_WINRADIO;
%ignore RIG_BACKEND_WINRADIO;
%ignore RIG_TENTEC;
%ignore RIG_BACKEND_TENTEC;
%ignore RIG_ALINCO;
%ignore RIG_BACKEND_ALINCO;
%ignore RIG_KACHINA;
%ignore RIG_BACKEND_KACHINA;
%ignore RIG_RPC;
%ignore RIG_BACKEND_RPC;
%ignore RIG_GNURADIO;
%ignore RIG_BACKEND_GNURADIO;
%ignore RIG_MICROTUNE;
%ignore RIG_BACKEND_MICROTUNE;
%ignore RIG_TAPR;
%ignore RIG_BACKEND_TAPR;
%ignore RIG_FLEXRADIO;
%ignore RIG_BACKEND_FLEXRADIO;
%ignore RIG_RFT;
%ignore RIG_BACKEND_RFT;
%ignore RIG_KIT;
%ignore RIG_BACKEND_KIT;
%ignore RIG_TUNER;
%ignore RIG_BACKEND_TUNER;
%ignore RIG_RS;
%ignore RIG_BACKEND_RS;
%ignore RIG_ADAT;
%ignore RIG_BACKEND_ADAT;
%ignore RIG_ICMARINE;
%ignore RIG_BACKEND_ICMARINE;
// remove defines from Hamlib class
%rename("$ignore", regexmatch$name="^_") "";
%rename("$ignore", regexmatch$name="^AMP_") "";
%rename("$ignore", regexmatch$name="^RIG_") "";
%rename("$ignore", regexmatch$name="^ROT_") "";
%ignore ROT_DUMMY;
%ignore ROT_BACKEND_DUMMY;
%ignore ROT_RPC;
%ignore ROT_BACKEND_RPC;
%ignore ROT_EASYCOMM;
%ignore ROT_BACKEND_EASYCOMM;
%ignore ROT_FODTRACK;
%ignore ROT_BACKEND_FODTRACK;
%ignore ROT_ROTOREZ;
%ignore ROT_BACKEND_ROTOREZ;
%ignore ROT_SARTEK;
%ignore ROT_BACKEND_SARTEK;
%ignore ROT_GS232A;
%ignore ROT_BACKEND_GS232A;
%ignore ROT_KIT;
%ignore ROT_BACKEND_KIT;
%ignore ROT_HEATHKIT;
%ignore ROT_BACKEND_HEATHKIT;
%ignore ROT_SPID;
%ignore ROT_BACKEND_SPID;
%ignore ROT_M2;
%ignore ROT_BACKEND_M2;
%ignore ROT_ARS;
%ignore ROT_BACKEND_ARS;
%ignore ROT_AMSAT;
%ignore ROT_BACKEND_AMSAT;
%ignore ROT_TS7400;
%ignore ROT_BACKEND_TS7400;
%ignore ROT_CELESTRON;
%ignore ROT_BACKEND_CELESTRON;
// re-add useful defines
%ignore PRIfreq;
%ignore SCNfreq;
%ignore FREQFMT;
// Amplifiers
%rename("%s", regexmatch$name="^AMP_FLAG_") "";
%rename("%s", regexmatch$name="^AMP_LEVEL_") "";
%rename("%s", regexmatch$name="^AMP_MODEL_") "";
%rename("%s", regexmatch$name="^AMP_RESET_") "";
%rename("%s", regexmatch$name="^AMP_TYPE_") "";
%ignore rig_open;
%ignore rig_set_freq;
%ignore rig_get_freq;
%ignore rig_set_mode;
%ignore rig_get_mode;
%ignore rig_set_vfo;
%ignore rig_get_vfo;
%ignore rig_set_ptt;
%ignore rig_get_ptt;
%ignore rig_get_dcd;
%ignore rig_set_rptr_shift;
%ignore rig_get_rptr_shift;
%ignore rig_set_rptr_offs;
%ignore rig_get_rptr_offs;
%ignore rig_set_ctcss_tone;
%ignore rig_get_ctcss_tone;
%ignore rig_set_dcs_code;
%ignore rig_get_dcs_code;
%ignore rig_set_ctcss_sql;
%ignore rig_get_ctcss_sql;
%ignore rig_set_dcs_sql;
%ignore rig_get_dcs_sql;
%ignore rig_set_split_freq;
%ignore rig_get_split_freq;
%ignore rig_set_split_mode;
%ignore rig_get_split_mode;
%ignore rig_set_split;
%ignore rig_get_split;
%ignore rig_set_rit;
%ignore rig_get_rit;
%ignore rig_set_xit;
%ignore rig_get_xit;
%ignore rig_set_ts;
%ignore rig_get_ts;
%ignore rig_power2mW;
%ignore rig_mW2power;
%ignore rig_get_resolution;
%ignore rig_set_level;
%ignore rig_get_level;
%ignore rig_set_parm;
%ignore rig_get_parm;
%ignore rig_set_conf;
%ignore rig_get_conf;
%ignore rig_set_powerstat;
%ignore rig_get_powerstat;
%ignore rig_reset;
%ignore rig_set_ext_level;
%ignore rig_get_ext_level;
%ignore rig_set_ext_parm;
%ignore rig_get_ext_parm;
%ignore rig_ext_level_foreach;
%ignore rig_ext_parm_foreach;
%ignore rig_token_lookup;
%ignore rig_close;
%ignore rig_cleanup;
%ignore rig_probe;
%ignore rig_set_ant;
%ignore rig_get_ant;
%ignore rig_has_get_level;
%ignore rig_has_set_level;
%ignore rig_has_get_parm;
%ignore rig_has_set_parm;
%ignore rig_has_get_func;
%ignore rig_has_set_func;
%ignore rig_set_func;
%ignore rig_get_func;
%ignore rig_send_dtmf;
%ignore rig_recv_dtmf;
%ignore rig_send_morse;
%ignore rig_set_bank;
%ignore rig_set_mem;
%ignore rig_get_mem;
%ignore rig_vfo_op;
%ignore rig_has_vfo_op;
%ignore rig_scan;
%ignore rig_has_scan;
%ignore rig_set_channel;
%ignore rig_get_channel;
%ignore rig_set_trn;
%ignore rig_get_trn;
%ignore rig_set_freq_callback;
%ignore rig_set_mode_callback;
%ignore rig_set_vfo_callback;
%ignore rig_set_ptt_callback;
%ignore rig_set_dcd_callback;
%ignore rig_set_pltune_callback;
%ignore rig_get_info;
%ignore rig_passband_normal;
%ignore rig_passband_narrow;
%ignore rig_passband_wide;
%ignore rig_get_vfo_info;
// Rigs
%rename("%s", regexmatch$name="^RIG_AGC_") "";
%rename("%s", regexmatch$name="^RIG_ANN_") "";
%rename("%s", regexmatch$name="^RIG_ANT_") "";
%rename("%s", regexmatch$name="^RIG_BANDSELECT_") "";
%rename("%s", regexmatch$name="^RIG_BAND_") "";
%rename("%s") RIG_BUSBUSY;
%rename("%s") RIG_BUSERROR;
%rename("%s", regexmatch$name="^RIG_CAPS_") "";
%rename("%s", regexmatch$name="^RIG_CHFLAG_") "";
%rename("%s", regexmatch$name="^RIG_CLIENT_") "";
%rename("%s", regexmatch$name="^RIG_COMM_") "";
%rename("%s", regexmatch$name="^RIG_CONF_") "";
%rename("%s", regexmatch$name="^RIG_COOKIE_") "";
%rename("%s", regexmatch$name="^RIG_DCD_") "";
%rename("%s", regexmatch$name="^RIG_DEBUG_") "";
%rename("%s", regexmatch$name="^RIG_E") "";
%rename("%s", regexmatch$name="^RIG_FLAG_") "";
%rename("%s", regexmatch$name="^RIG_FLT_") "";
%rename("%s", regexmatch$name="^RIG_FUNCTION_") "";
%rename("%s", regexmatch$name="^RIG_FUNC_") "";
%rename("%s", regexmatch$name="^RIG_HANDSHAKE_") "";
%rename("%s", regexmatch$name="^RIG_KEYERTYPE_") "";
%rename("%s", regexmatch$name="^RIG_LEVEL_") "";
%rename("%s", regexmatch$name="^RIG_MEM_CAPS_") "";
%rename("%s", regexmatch$name="^RIG_METER_") "";
%rename("%s", regexmatch$name="^RIG_MODEL_") "";
%rename("%s", regexmatch$name="^RIG_MODE_") "";
%rename("%s", regexmatch$name="^RIG_MTYPE_") "";
%rename("%s", regexmatch$name="^RIG_MULTICAST_") "";
%rename("%s", regexmatch$name="^RIG_OP_") "";
%rename("%s") RIG_OK;
%rename("%s", regexmatch$name="^RIG_PARITY_") "";
%rename("%s", regexmatch$name="^RIG_PARM_") "";
%rename("%s", regexmatch$name="^RIG_PORT_") "";
%rename("%s", regexmatch$name="^RIG_POWER_") "";
%rename("%s", regexmatch$name="^RIG_PTRX_") "";
%rename("%s", regexmatch$name="^RIG_PTT_") "";
%rename("%s", regexmatch$name="^RIG_RESET_") "";
%rename("%s", regexmatch$name="^RIG_RPT_SHIFT_") "";
%rename("%s", regexmatch$name="^RIG_SCAN_") "";
%rename("%s", regexmatch$name="^RIG_SETTING_") "";
%rename("%s", regexmatch$name="^RIG_SIGNAL_") "";
%rename("%s", regexmatch$name="^RIG_SPECTRUM_MODE_") "";
%rename("%s", regexmatch$name="^RIG_SPLIT_") "";
%rename("%s", regexmatch$name="^RIG_STATUS_") "";
%rename("%s", regexmatch$name="^RIG_TARGETABLE_") "";
%rename("%s", regexmatch$name="^RIG_TRN_") "";
%rename("%s", regexmatch$name="^RIG_TS_") "";
%rename("%s", regexmatch$name="^RIG_TYPE_") "";
%rename("%s", regexmatch$name="^RIG_VFO_") "";
%ignore RIG_EK; // an internal macro
%ignore RIG_ELAD; // an internal macro
%ignore rot_open;
%ignore rot_close;
%ignore rot_cleanup;
%ignore rot_set_conf;
%ignore rot_get_conf;
%ignore rot_set_position;
%ignore rot_get_position;
%ignore rot_stop;
%ignore rot_park;
%ignore rot_reset;
%ignore rot_move;
%ignore rot_get_info;
// Rotators
%rename("%s", regexmatch$name="^ROT_FLAG_") "";
%rename("%s", regexmatch$name="^ROT_FUNC_") "";
%rename("%s", regexmatch$name="^ROT_LEVEL_") "";
%rename("%s", regexmatch$name="^ROT_MODEL_") "";
%rename("%s", regexmatch$name="^ROT_MOVE_") "";
%rename("%s", regexmatch$name="^ROT_PARM_") "";
%rename("%s", regexmatch$name="^ROT_RESET_") "";
%rename("%s", regexmatch$name="^ROT_SPEED_") "";
%rename("%s", regexmatch$name="^ROT_STATUS_") "";
%rename("%s", regexmatch$name="^ROT_TYPE_") "";
// remove methods from Hamlib class
%rename("$ignore", regexmatch$name="^amp_", %$isfunction) "";
%rename("$ignore", regexmatch$name="^rig_", %$isfunction) "";
%rename("$ignore", regexmatch$name="^rot_", %$isfunction) "";
// re-add some methods
%rename("%s") rig_set_debug;
%rename("%s", regexmatch$name="^rig_str", %$isfunction) "";
// remove typedefs
%ignore s_rig;
%ignore s_rot;
%ignore amp;
%ignore debugmsgsave;
%ignore debugmsgsave2;
%ignore debugmsgsave3;
%ignore hamlib_copyright2;
%ignore hamlib_version2;
%ignore macro_name;
@ -216,8 +106,10 @@
%ignore fd_sync_error_write;
%ignore fd_sync_error_read;
%ignore FIFO_RIG;
%ignore FREQFMT;
%ignore PRIfreq;
%ignore SCNfreq;
#ifdef SWIGLUA
%ignore Rig::set_level(setting_t,int,vfo_t);

Wyświetl plik

@ -0,0 +1,92 @@
/*
Common SWIG macros
*/
/*
* Macro GET_TOKEN
*
* function_prefix:
* the first part of the function name (eg. one of: amp_ rig_ rot_)
*
* function_name:
* the name that will be seen in the bindings and that creates a valid Hamlib function
* name when appended to the function_prefix
*
* class_pointer:
* the pointer to the instance of the class (eg. one of self->amp self->rig self->rot)
*/
%define GET_TOKEN(function_prefix, function_name, class_pointer)
PyObject * ##function_name(hamlib_token_t token)
{
int value;
self->error_status = ##function_prefix ##function_name(##class_pointer, token, &value);
if (self->error_status != RIG_OK)
return Py_None;
return PyLong_FromLong(value);
}
%enddef
/*
* Macro GET_VALUE_T
*
* function_prefix:
* the first part of the function name (eg. one of: amp_ rig_ rot_)
*
* function_name:
* the name that creates a valid Hamlib function name when appended to the
* function_prefix
*
* class_pointer:
* the pointer to the instance of the class (eg. one of self->amp self->rig self->rot)
*
* level_prefix:
* the prefix of the macro that checks the datatype (eg. one of AMP_ RIG_ ROT_)
*/
%define GET_VALUE_T(function_prefix, function_name, class_pointer, level_prefix)
PyObject * ##function_name(hamlib_token_t token)
{
value_t value;
self->error_status = ##function_prefix ##function_name(##class_pointer, token, &value);
if (self->error_status != RIG_OK)
return Py_None;
#if defined(##level_prefix LEVEL_IS_FLOAT)
if (##level_prefix LEVEL_IS_FLOAT(token))
return PyFloat_FromDouble(value.f);
#endif
#if defined(##level_prefix LEVEL_IS_STRING)
if (##level_prefix LEVEL_IS_STRING(token))
return PyUnicode_FromString(value.s);
#endif
return PyLong_FromLong(value.i);
}
%enddef
/*
* Macro ROT_GET_LONG
*
* function_name:
* the name that will be seen in the bindings when appended to get_
* and that creates a valid Hamlib function when appended to rot_get_
* eg. ROT_GET_LONG(func) creates Rot.get_func() that calls rot_get_func()
*/
%define ROT_GET_LONG(function_name)
GET_TOKEN(rot_, get_ ##function_name, self->rot)
%enddef
/*
* Macro ROT_GET_VALUE_T
*
* function_name:
* the name that will be seen in the bindings when appended to get_
* and that creates a valid Hamlib function when appended to rot_get_
* eg. ROT_GET_VALUE_T(level) creates Rot.get_level() that calls rot_get_level()
*/
%define ROT_GET_VALUE_T(function_name)
GET_VALUE_T(rot_, get_ ##function_name, self->rot, ROT_)
%enddef

Wyświetl plik

@ -1,129 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# Change this path to match your "make install" path
sys.path.append('/usr/local/lib/python3.10/site-packages')
## Uncomment to run this script from an in-tree build (or adjust to the
## build directory) without installing the bindings.
#sys.path.append ('.')
#sys.path.append ('.libs')
import Hamlib
def StartUp():
"""Simple script to test the Hamlib.py module with Python3."""
print("%s: Python %s; %s\n" \
% (sys.argv[0], sys.version.split()[0], Hamlib.cvar.hamlib_version))
Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
# Init RIG_MODEL_DUMMY
my_rig = Hamlib.Rig(Hamlib.RIG_MODEL_DUMMY)
my_rig.set_conf("rig_pathname", "/dev/Rig")
my_rig.set_conf("retry", "5")
my_rig.open ()
rpath = my_rig.get_conf("rig_pathname")
retry = my_rig.get_conf("retry")
print("status(str):\t\t%s" % Hamlib.rigerror(my_rig.error_status))
print("get_conf:\t\tpath = %s, retry = %s" \
% (rpath, retry))
my_rig.set_freq(Hamlib.RIG_VFO_B, 5700000000)
my_rig.set_vfo(Hamlib.RIG_VFO_B)
print("freq:\t\t\t%s" % my_rig.get_freq())
my_rig.set_freq(Hamlib.RIG_VFO_A, 145550000)
(mode, width) = my_rig.get_mode(Hamlib.RIG_VFO_A)
print("mode:\t\t\t%s\nbandwidth:\t\t%s" % (Hamlib.rig_strrmode(mode), width))
my_rig.set_mode(Hamlib.RIG_MODE_CW)
(mode, width) = my_rig.get_mode()
print("mode:\t\t\t%s\nbandwidth:\t\t%s" % (Hamlib.rig_strrmode(mode), width))
print("Backend copyright:\t%s" % my_rig.caps.copyright)
print("Model:\t\t\t%s" % my_rig.caps.model_name)
print("Manufacturer:\t\t%s" % my_rig.caps.mfg_name)
print("Backend version:\t%s" % my_rig.caps.version)
print("Backend status:\t\t%s" % Hamlib.rig_strstatus(my_rig.caps.status))
print("Rig info:\t\t%s" % my_rig.get_info())
my_rig.set_level("VOXDELAY", 1)
print("VOX delay:\t\t%s" % my_rig.get_level_i("VOXDELAY"))
my_rig.set_level(Hamlib.RIG_LEVEL_VOXDELAY, 5)
print("VOX delay:\t\t%s" % my_rig.get_level_i(Hamlib.RIG_LEVEL_VOXDELAY))
af = 12.34
print("Setting AF to %0.2f...." % (af))
my_rig.set_level("AF", af)
print("status:\t\t\t%s - %s" % (my_rig.error_status,
Hamlib.rigerror(my_rig.error_status)))
print("AF level:\t\t%0.2f" % my_rig.get_level_f(Hamlib.RIG_LEVEL_AF))
print("Power level:\t\t%0.2f" % my_rig.get_level_f(Hamlib.RIG_LEVEL_RFPOWER_METER))
print("Power level Watts:\t\t%0.2f" % my_rig.get_level_f(Hamlib.RIG_LEVEL_RFPOWER_METER_WATTS))
print("strength:\t\t%s" % my_rig.get_level_i(Hamlib.RIG_LEVEL_STRENGTH))
print("status:\t\t\t%s" % my_rig.error_status)
print("status(str):\t\t%s" % Hamlib.rigerror(my_rig.error_status))
chan = Hamlib.channel(Hamlib.RIG_VFO_B)
my_rig.get_channel(chan,1)
print("get_channel status:\t%s" % my_rig.error_status)
print("VFO:\t\t\t%s, %s" % (Hamlib.rig_strvfo(chan.vfo), chan.freq))
print("Attenuators:\t\t%s" % my_rig.caps.attenuator)
# Can't seem to get get_vfo_info to work
#(freq, width, mode, split) = my_rig.get_vfo_info(Hamlib.RIG_VFO_A,freq,width,mode,split)
#print("Rig vfo_info:\t\tfreq=%s, mode=%s, width=%s, split=%s" % (freq, mode, width, split))
print("\nSending Morse, '73'")
my_rig.send_morse(Hamlib.RIG_VFO_A, "73")
my_rig.close()
print("\nSome static functions:")
err, lon1, lat1 = Hamlib.locator2longlat("IN98XC")
err, lon2, lat2 = Hamlib.locator2longlat("DM33DX")
err, loc1 = Hamlib.longlat2locator(lon1, lat1, 3)
err, loc2 = Hamlib.longlat2locator(lon2, lat2, 3)
print("Loc1:\t\tIN98XC -> %9.4f, %9.4f -> %s" % (lon1, lat1, loc1))
print("Loc2:\t\tDM33DX -> %9.4f, %9.4f -> %s" % (lon2, lat2, loc2))
err, dist, az = Hamlib.qrb(lon1, lat1, lon2, lat2)
longpath = Hamlib.distance_long_path(dist)
print("Distance:\t%.3f km, azimuth %.2f, long path:\t%.3f km" \
% (dist, az, longpath))
# dec2dms expects values from 180 to -180
# sw is 1 when deg is negative (west or south) as 0 cannot be signed
err, deg1, mins1, sec1, sw1 = Hamlib.dec2dms(lon1)
err, deg2, mins2, sec2, sw2 = Hamlib.dec2dms(lat1)
lon3 = Hamlib.dms2dec(deg1, mins1, sec1, sw1)
lat3 = Hamlib.dms2dec(deg2, mins2, sec2, sw2)
print('Longitude:\t%4.4f, %4d° %2d\' %2d" %1s\trecoded: %9.4f' \
% (lon1, deg1, mins1, sec1, ('W' if sw1 else 'E'), lon3))
print('Latitude:\t%4.4f, %4d° %2d\' %2d" %1s\trecoded: %9.4f' \
% (lat1, deg2, mins2, sec2, ('S' if sw2 else 'N'), lat3))
my_rig.set_vfo_opt(0);
if __name__ == '__main__':
StartUp()

Wyświetl plik

@ -1,122 +0,0 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import sys
## Uncomment to run this script from an in-tree build (or adjust to the
## build directory) without installing the bindings.
#sys.path.append ('.')
#sys.path.append ('.libs')
import Hamlib
def StartUp(verbose):
"""Simple script to test the Hamlib.py module with Python2."""
print "%s: Python %s; %s\n" \
% (sys.argv[0], sys.version.split()[0], Hamlib.cvar.hamlib_version)
Hamlib.rig_set_debug([Hamlib.RIG_DEBUG_NONE, Hamlib.RIG_DEBUG_VERBOSE][verbose])
# Init RIG_MODEL_DUMMY
my_rig = Hamlib.Rig(Hamlib.RIG_MODEL_DUMMY)
my_rig.set_conf("rig_pathname", "/dev/Rig")
my_rig.set_conf("retry", "5")
my_rig.open()
rpath = my_rig.get_conf("rig_pathname")
retry = my_rig.get_conf("retry")
print "status(str):\t\t", Hamlib.rigerror(my_rig.error_status)
print "get_conf:\t\tpath = %s, retry = %s" \
% (rpath, retry)
my_rig.set_freq(Hamlib.RIG_VFO_B, 5700000000)
my_rig.set_vfo(Hamlib.RIG_VFO_B)
print "freq:\t\t\t", my_rig.get_freq()
my_rig.set_freq(Hamlib.RIG_VFO_A, 145550000)
(mode, width) = my_rig.get_mode()
print "mode:\t\t\t", Hamlib.rig_strrmode(mode), "\nbandwidth:\t\t", width
my_rig.set_mode(Hamlib.RIG_MODE_CW)
(mode, width) = my_rig.get_mode()
print "mode:\t\t\t", Hamlib.rig_strrmode(mode), "\nbandwidth:\t\t", width
print "Backend copyright:\t", my_rig.caps.copyright
print "Model:\t\t\t", my_rig.caps.model_name
print "Manufacturer:\t\t", my_rig.caps.mfg_name
print "Backend version:\t", my_rig.caps.version
print "Backend status:\t\t", Hamlib.rig_strstatus(my_rig.caps.status)
print "Rig info:\t\t", my_rig.get_info()
my_rig.set_level("VOXDELAY", 1)
print "VOX delay:\t\t", my_rig.get_level_i("VOXDELAY")
my_rig.set_level(Hamlib.RIG_LEVEL_VOXDELAY, 5)
print "VOX delay:\t\t", my_rig.get_level_i(Hamlib.RIG_LEVEL_VOXDELAY)
af = 12.34
print "Setting AF to %0.2f...." % (af)
my_rig.set_level("AF", af)
print "status:\t\t\t%s - %s" % (my_rig.error_status,
Hamlib.rigerror(my_rig.error_status))
print "AF level:\t\t%0.2f" % my_rig.get_level_f(Hamlib.RIG_LEVEL_AF)
print "strength:\t\t", my_rig.get_level_i(Hamlib.RIG_LEVEL_STRENGTH)
print "status:\t\t\t", my_rig.error_status
print "status(str):\t\t", Hamlib.rigerror(my_rig.error_status)
chan = Hamlib.channel(Hamlib.RIG_VFO_B)
my_rig.get_channel(chan,1)
print "get_channel status:\t", my_rig.error_status
print "VFO:\t\t\t", Hamlib.rig_strvfo(chan.vfo), ", ", chan.freq
print "Attenuators:\t\t", my_rig.caps.attenuator
print "\nSending Morse, '73'"
my_rig.send_morse(Hamlib.RIG_VFO_A, "73")
my_rig.close ()
print "\nSome static functions:"
err, lon1, lat1 = Hamlib.locator2longlat("IN98XC")
err, lon2, lat2 = Hamlib.locator2longlat("DM33DX")
err, loc1 = Hamlib.longlat2locator(lon1, lat1, 3)
err, loc2 = Hamlib.longlat2locator(lon2, lat2, 3)
print "Loc1:\t\tIN98XC -> %9.4f, %9.4f -> %s" % (lon1, lat1, loc1)
print "Loc2:\t\tDM33DX -> %9.4f, %9.4f -> %s" % (lon2, lat2, loc2)
err, dist, az = Hamlib.qrb(lon1, lat1, lon2, lat2)
longpath = Hamlib.distance_long_path(dist)
print "Distance:\t%.3f km, azimuth %.2f, long path:\t%.3f km" \
% (dist, az, longpath)
# dec2dms expects values from 180 to -180
# sw is 1 when deg is negative (west or south) as 0 cannot be signed
err, deg1, mins1, sec1, sw1 = Hamlib.dec2dms(lon1)
err, deg2, mins2, sec2, sw2 = Hamlib.dec2dms(lat1)
lon3 = Hamlib.dms2dec(deg1, mins1, sec1, sw1)
lat3 = Hamlib.dms2dec(deg2, mins2, sec2, sw2)
print 'Longitude:\t%4.4f, %4d° %2d\' %2d" %1s\trecoded: %9.4f' \
% (lon1, deg1, mins1, sec1, ('W' if sw1 else 'E'), lon3)
print 'Latitude:\t%4.4f, %4d° %2d\' %2d" %1s\trecoded: %9.4f' \
% (lat1, deg2, mins2, sec2, ('S' if sw2 else 'N'), lat3)
if __name__ == '__main__':
StartUp([0,1]["-v" in sys.argv])

Wyświetl plik

@ -0,0 +1,92 @@
#! /bin/env python
"""
Creates tests for the Python bindings for Hamlib
Running this script directly will use the installed bindings.
For an in-tree run use "make check", or set PYTHONPATH to point to
the directories containing Hamlib.py and _Hamlib.so.
"""
import inspect
import os
import sys
import Hamlib
# This class gets copied to the generated file with replacements
class TestClass:
"""A pytest class for {object_name}"""
@classmethod
def setup_class(cls):
"""Common initialization before calling test methods"""
cls.actual_callables, cls.actual_properties = cls.generate_data({object_name})
def test_callables(self):
"""Check that nothing was added or removed"""
expected_callables = {expected_callables}
assert expected_callables == self.actual_callables
def test_properties(self):
"""Check that nothing was added or removed"""
expected_properties = {expected_properties}
assert expected_properties == self.actual_properties
@classmethod
def generate_data(cls, the_object):
"""Extract callables and properties from the given object"""
callables = []
properties = []
for method_or_property in dir(the_object):
if not method_or_property.startswith("_"):
if callable(getattr(the_object, method_or_property)):
callables.append(method_or_property)
else:
properties.append(method_or_property)
return callables, properties
def generate_file(object_name, callables, properties):
"""Create a complete file for pytest"""
file_header = '''#! /bin/env pytest
"""
Tests of the Python bindings for Hamlib
DO NOT EDIT this autogenerated file, run "make generate-pytests" instead
"""
import Hamlib
'''
filename = f"test_{object_name.replace(".", "_")}_class.py"
class_source = inspect.getsource(TestClass)
expected_callables = repr(callables)
expected_properties = repr(properties)
print(f"Generating {filename}")
with open(filename, "w", encoding='utf-8') as output_file:
print(file_header, file=output_file)
print(class_source.format(
object_name=object_name,
expected_callables=expected_callables,
expected_properties=expected_properties),
file=output_file, end='')
if __name__ == "__main__":
if len(sys.argv) == 2 and not sys.argv[1].startswith("-"):
os.chdir(sys.argv[1])
else:
print("Usage: {sys.argv[0]} [OUTPUT_DIRECTORY]", file=sys.stderr)
sys.exit(1)
for the_object in (
Hamlib,
Hamlib.Amp,
Hamlib.Rig,
Hamlib.Rot,
):
try:
full_name = f"{the_object.__module__}.{the_object.__name__}"
except AttributeError:
full_name = the_object.__name__
expected_callables, expected_properties = TestClass.generate_data(the_object)
generate_file(full_name, expected_callables, expected_properties)

Wyświetl plik

@ -0,0 +1,39 @@
#! /bin/env pytest
"""
Tests of the Python bindings for Hamlib
DO NOT EDIT this autogenerated file, run "make generate-pytests" instead
"""
import Hamlib
class TestClass:
"""A pytest class for Hamlib.Amp"""
@classmethod
def setup_class(cls):
"""Common initialization before calling test methods"""
cls.actual_callables, cls.actual_properties = cls.generate_data(Hamlib.Amp)
def test_callables(self):
"""Check that nothing was added or removed"""
expected_callables = ['close', 'get_conf', 'get_freq', 'get_info', 'get_level', 'get_powerstat', 'open', 'reset', 'set_conf', 'set_freq', 'set_powerstat', 'token_lookup']
assert expected_callables == self.actual_callables
def test_properties(self):
"""Check that nothing was added or removed"""
expected_properties = ['caps', 'do_exception', 'error_status', 'state', 'thisown']
assert expected_properties == self.actual_properties
@classmethod
def generate_data(cls, the_object):
"""Extract callables and properties from the given object"""
callables = []
properties = []
for method_or_property in dir(the_object):
if not method_or_property.startswith("_"):
if callable(getattr(the_object, method_or_property)):
callables.append(method_or_property)
else:
properties.append(method_or_property)
return callables, properties

Wyświetl plik

@ -0,0 +1,39 @@
#! /bin/env pytest
"""
Tests of the Python bindings for Hamlib
DO NOT EDIT this autogenerated file, run "make generate-pytests" instead
"""
import Hamlib
class TestClass:
"""A pytest class for Hamlib.Rig"""
@classmethod
def setup_class(cls):
"""Common initialization before calling test methods"""
cls.actual_callables, cls.actual_properties = cls.generate_data(Hamlib.Rig)
def test_callables(self):
"""Check that nothing was added or removed"""
expected_callables = ['close', 'ext_token_lookup', 'get_ant', 'get_chan_all', 'get_channel', 'get_conf', 'get_ctcss_sql', 'get_ctcss_tone', 'get_dcd', 'get_dcs_code', 'get_dcs_sql', 'get_ext_func', 'get_ext_level', 'get_ext_parm', 'get_freq', 'get_func', 'get_info', 'get_level', 'get_level_f', 'get_level_i', 'get_mem', 'get_mode', 'get_parm', 'get_parm_f', 'get_parm_i', 'get_powerstat', 'get_ptt', 'get_rit', 'get_rptr_offs', 'get_rptr_shift', 'get_split_freq', 'get_split_mode', 'get_split_vfo', 'get_trn', 'get_ts', 'get_vfo', 'get_vfo_info', 'get_xit', 'has_get_level', 'has_scan', 'has_set_func', 'has_set_parm', 'has_vfo_op', 'lookup_mem_caps', 'mem_count', 'open', 'passband_narrow', 'passband_normal', 'passband_wide', 'recv_dtmf', 'reset', 'scan', 'send_dtmf', 'send_morse', 'set_ant', 'set_bank', 'set_channel', 'set_conf', 'set_ctcss_sql', 'set_ctcss_tone', 'set_dcs_code', 'set_dcs_sql', 'set_ext_func', 'set_ext_level', 'set_ext_parm', 'set_freq', 'set_func', 'set_level', 'set_mem', 'set_mode', 'set_parm', 'set_powerstat', 'set_ptt', 'set_rit', 'set_rptr_offs', 'set_rptr_shift', 'set_split_freq', 'set_split_freq_mode', 'set_split_mode', 'set_split_vfo', 'set_trn', 'set_ts', 'set_vfo', 'set_vfo_opt', 'set_xit', 'token_lookup', 'vfo_op']
assert expected_callables == self.actual_callables
def test_properties(self):
"""Check that nothing was added or removed"""
expected_properties = ['caps', 'do_exception', 'error_status', 'rig', 'state', 'thisown']
assert expected_properties == self.actual_properties
@classmethod
def generate_data(cls, the_object):
"""Extract callables and properties from the given object"""
callables = []
properties = []
for method_or_property in dir(the_object):
if not method_or_property.startswith("_"):
if callable(getattr(the_object, method_or_property)):
callables.append(method_or_property)
else:
properties.append(method_or_property)
return callables, properties

Wyświetl plik

@ -0,0 +1,39 @@
#! /bin/env pytest
"""
Tests of the Python bindings for Hamlib
DO NOT EDIT this autogenerated file, run "make generate-pytests" instead
"""
import Hamlib
class TestClass:
"""A pytest class for Hamlib.Rot"""
@classmethod
def setup_class(cls):
"""Common initialization before calling test methods"""
cls.actual_callables, cls.actual_properties = cls.generate_data(Hamlib.Rot)
def test_callables(self):
"""Check that nothing was added or removed"""
expected_callables = ['close', 'get_conf', 'get_ext_func', 'get_ext_level', 'get_ext_parm', 'get_func', 'get_info', 'get_level', 'get_parm', 'get_position', 'move', 'open', 'park', 'reset', 'set_conf', 'set_ext_func', 'set_ext_level', 'set_ext_parm', 'set_func', 'set_level', 'set_parm', 'set_position', 'stop', 'token_lookup']
assert expected_callables == self.actual_callables
def test_properties(self):
"""Check that nothing was added or removed"""
expected_properties = ['caps', 'do_exception', 'error_status', 'rot', 'state', 'thisown']
assert expected_properties == self.actual_properties
@classmethod
def generate_data(cls, the_object):
"""Extract callables and properties from the given object"""
callables = []
properties = []
for method_or_property in dir(the_object):
if not method_or_property.startswith("_"):
if callable(getattr(the_object, method_or_property)):
callables.append(method_or_property)
else:
properties.append(method_or_property)
return callables, properties

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -0,0 +1,118 @@
#! /bin/env pytest
"""Tests of the Python bindings for Hamlib
Running this script directly will use the installed bindings.
For an in-tree run use "make check", or set PYTHONPATH to point to
the directories containing Hamlib.py and _Hamlib.so.
"""
import Hamlib
Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
AMP_MODEL = Hamlib.AMP_MODEL_DUMMY
class TestClass:
"""Container class for tests"""
def test_without_open(self):
"""Call all the methods that do not depend on open()"""
amp = Hamlib.Amp(AMP_MODEL)
assert amp is not None
assert amp.do_exception == 0
assert amp.error_status == Hamlib.RIG_OK
assert isinstance(amp.caps.model_name, str)
assert isinstance(amp.caps.mfg_name, str)
assert isinstance(amp.caps.version, str)
assert isinstance(amp.caps.copyright, str)
assert amp.set_conf("", "") is None
assert amp.get_conf("") == ""
assert amp.get_conf(0) == ""
conf = amp.get_conf("mcfg")
assert isinstance(conf, str)
assert amp.set_conf("mcfg", "foo") is None
conf = amp.get_conf("mcfg")
assert conf == "" # FIXME: should return "foo"
assert amp.token_lookup("") is None
def test_with_open(self):
"""Call all the methods that depend on open()"""
amp = Hamlib.Amp(AMP_MODEL)
assert amp is not None
assert amp.state.comm_state == 0
assert amp.open() is None
assert amp.state.comm_state == 1
info = amp.get_info()
assert isinstance(info, str)
assert amp.reset(Hamlib.AMP_RESET_FAULT) is None
assert amp.set_freq(0) is None
assert amp.set_freq(123.45) is None
assert amp.get_freq() == 123.45
assert amp.get_level(Hamlib.AMP_LEVEL_NONE) is None
level = amp.get_level(Hamlib.AMP_LEVEL_SWR)
assert isinstance(level, float)
level = amp.get_level(Hamlib.AMP_LEVEL_PWR_REFLECTED)
assert isinstance(level, int)
level = amp.get_level(Hamlib.AMP_LEVEL_FAULT)
assert isinstance(level, str)
level = amp.get_level(123456)
assert level is None
assert amp.set_powerstat(Hamlib.RIG_POWER_ON) is None
assert amp.get_powerstat() == Hamlib.RIG_POWER_ON
assert amp.close() is None
def test_all_methods(self):
"""Just call all the methods"""
amp = Hamlib.Amp(AMP_MODEL)
assert amp is not None
# the tests that do not depend on open()
assert amp.set_conf("", "") is None
assert amp.get_conf("") == ""
assert amp.get_conf(0) == ""
conf = amp.get_conf("mcfg")
assert isinstance(conf, str)
assert amp.set_conf("mcfg", "foo") is None
conf = amp.get_conf("mcfg")
assert conf == "" # FIXME: should return "foo"
assert amp.token_lookup("") is None
# the tests that depend on open()
assert amp.state.comm_state == 0
assert amp.open() is None
assert amp.state.comm_state == 1
info = amp.get_info()
assert isinstance(info, str)
assert amp.reset(Hamlib.AMP_RESET_FAULT) is None
assert amp.set_freq(0) is None
assert amp.set_freq(123.45) is None
assert amp.get_freq() == 123.45
assert amp.get_level(Hamlib.AMP_LEVEL_NONE) is None
level = amp.get_level(Hamlib.AMP_LEVEL_SWR)
assert isinstance(level, float)
level = amp.get_level(Hamlib.AMP_LEVEL_PWR_REFLECTED)
assert isinstance(level, int)
level = amp.get_level(Hamlib.AMP_LEVEL_FAULT)
assert isinstance(level, str)
level = amp.get_level(123456)
assert level is None
assert amp.set_powerstat(Hamlib.RIG_POWER_ON) is None
assert amp.get_powerstat() == Hamlib.RIG_POWER_ON
assert amp.close() is None
assert amp.state.comm_state == 0
info = amp.get_info()
assert info is None
def test_object_creation(self):
"""Create all objects available"""
amp = Hamlib.Rig(AMP_MODEL)
assert amp is not None
assert isinstance(amp.caps, Hamlib.rig_caps)
assert isinstance(amp.state, Hamlib.rig_state)

Wyświetl plik

@ -0,0 +1,216 @@
#! /bin/env pytest
"""Tests of the Python bindings for Hamlib
Running this script directly will use the installed bindings.
For an in-tree run use "make check", or set PYTHONPATH to point to
the directories containing Hamlib.py and _Hamlib.so.
"""
from pytest import raises
import Hamlib
Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
RIG_MODEL = Hamlib.RIG_MODEL_DUMMY
class TestClass:
"""Container class for tests"""
def test_without_open(self):
"""Call all the methods that do not depend on open()"""
rig = Hamlib.Rig(RIG_MODEL)
assert rig is not None
assert rig.do_exception == 0
assert rig.error_status == Hamlib.RIG_OK
assert isinstance(rig.caps.model_name, str)
assert isinstance(rig.caps.mfg_name, str)
assert isinstance(rig.caps.version, str)
assert isinstance(rig.caps.copyright, str)
assert rig.set_conf("", "") is None
assert rig.get_conf("") == ""
assert rig.get_conf(0) == ""
conf = rig.get_conf("mcfg")
assert isinstance(conf, str)
assert rig.set_conf("mcfg", "foo") is None
conf = rig.get_conf("mcfg")
assert conf == "foo"
assert rig.token_lookup("") is None
def test_with_open(self):
"""Call all the methods that depend on open()"""
rig = Hamlib.Rig(RIG_MODEL)
assert rig is not None
assert rig.state.comm_state == 0
assert rig.open() is None
assert rig.state.comm_state == 1
info = rig.get_info()
assert isinstance(info, str)
assert rig.close() is None
assert rig.state.comm_state == 0
info = rig.get_info()
assert info is None
def test_misc(self):
"""Just call all the methods"""
rig = Hamlib.Rig(RIG_MODEL)
assert rig is not None
assert rig.close() is None
assert rig.ext_token_lookup("") is None
option = Hamlib.value_t()
ant = 0 # FIXME should use a RIG_ANT_* constant but it isn't available in the bindings
assert isinstance(rig.get_ant(option, ant), list)
assert isinstance(rig.get_ant(option, ant, Hamlib.RIG_VFO_CURR), list)
assert option.i == 0
assert rig.get_chan_all() is None
channel = 0
readonly = 0
assert isinstance(rig.get_channel(channel), Hamlib.channel)
assert isinstance(rig.get_channel(channel, Hamlib.RIG_VFO_CURR), Hamlib.channel)
assert isinstance(rig.get_channel(channel, Hamlib.RIG_VFO_CURR, readonly), Hamlib.channel)
assert isinstance(rig.get_conf(""), str)
assert isinstance(rig.get_ctcss_sql(), int)
assert isinstance(rig.get_ctcss_sql(0), int)
assert isinstance(rig.get_ctcss_tone(), int)
assert isinstance(rig.get_ctcss_tone(0), int)
assert isinstance(rig.get_dcd(), int)
assert isinstance(rig.get_dcd(Hamlib.RIG_VFO_CURR,), int)
assert isinstance(rig.get_dcs_code(), int)
assert isinstance(rig.get_dcs_code(0), int)
assert isinstance(rig.get_dcs_sql(), int)
assert isinstance(rig.get_dcs_sql(0), int)
assert isinstance(rig.get_ext_func(0), int)
assert isinstance(rig.get_ext_func(0, 0), int)
assert rig.get_ext_level(0) is None
assert rig.get_ext_level(0, 0) is None
assert rig.get_ext_parm(0) is None
assert isinstance(rig.get_freq(), float)
assert isinstance(rig.get_freq(Hamlib.RIG_VFO_CURR), float)
assert isinstance(rig.get_func(0), int)
assert isinstance(rig.get_func(0, 0), int)
assert rig.get_info() is None
assert rig.get_level(0) is None
assert isinstance(rig.get_level_f(0), float)
assert isinstance(rig.get_level_i(0), int)
assert isinstance(rig.get_mem(), int)
assert isinstance(rig.get_mem(Hamlib.RIG_VFO_CURR), int)
assert isinstance(rig.get_mode(), list)
assert isinstance(rig.get_mode(Hamlib.RIG_VFO_CURR), list)
assert rig.get_parm(0) is None
assert isinstance(rig.get_parm_f(0), float)
assert isinstance(rig.get_parm_i(0), int)
assert isinstance(rig.get_powerstat(), int)
assert isinstance(rig.get_ptt(), int)
assert isinstance(rig.get_ptt(Hamlib.RIG_VFO_CURR), int)
assert isinstance(rig.get_rit(), int)
assert isinstance(rig.get_rit(Hamlib.RIG_VFO_CURR), int)
assert isinstance(rig.get_rptr_offs(), int)
assert isinstance(rig.get_rptr_offs(Hamlib.RIG_VFO_CURR), int)
assert isinstance(rig.get_rptr_shift(), int)
assert isinstance(rig.get_rptr_shift(Hamlib.RIG_VFO_CURR), int)
assert isinstance(rig.get_split_freq(), float)
assert isinstance(rig.get_split_freq(Hamlib.RIG_VFO_CURR), float)
assert isinstance(rig.get_split_mode(), list)
assert isinstance(rig.get_split_mode(Hamlib.RIG_VFO_CURR), list)
with raises(TypeError):
assert rig.get_split_vfo() is None # FIXME
assert rig.get_split_vfo(Hamlib.RIG_VFO_CURR) is None # FIXME
assert isinstance(rig.get_trn(), int) # deprecated
assert isinstance(rig.get_ts(), int)
assert isinstance(rig.get_ts(Hamlib.RIG_VFO_CURR), int)
assert isinstance(rig.get_vfo(), int)
with raises(TypeError):
assert rig.get_vfo_info(Hamlib.RIG_VFO_CURR) is None # FIXME
assert rig.get_vfo_info(Hamlib.RIG_VFO_CURR, 2) is None # FIXME
assert rig.get_vfo_info(Hamlib.RIG_VFO_CURR, 2, 3) is None # FIXME
assert isinstance(rig.get_xit(), int)
assert isinstance(rig.get_xit(Hamlib.RIG_VFO_CURR), int)
# assert rig_has_get_func(0) FIXME not defined
assert rig.has_get_level(0) is None # FIXME should return setting_t
# assert rig_has_get_parm(0) FIXME not defined
assert rig.has_scan(0) is None # FIXME should return scan_t
assert rig.has_set_func(0) is None # FIXME should return setting_t
# assert rig_has_set_level(0) FIXME not defined
assert rig.has_set_parm(0) is None # FIXME should return setting_t
assert rig.has_vfo_op(0) is None # FIXME should return vfo_op_t
assert rig.lookup_mem_caps() is None
assert rig.lookup_mem_caps(0) is None
assert isinstance(rig.mem_count(), int)
assert rig.open() is None
assert rig.passband_narrow(0) is None
assert rig.passband_normal(0) is None
assert rig.passband_wide(0) is None
assert isinstance(rig.recv_dtmf(), str)
assert isinstance(rig.recv_dtmf(0), str)
assert rig.reset(Hamlib.RIG_RESET_NONE) is None
assert rig.scan(0, 0) is None
assert rig.scan(0, 0, 0) is None
assert rig.send_dtmf(0, "") is None
assert rig.send_morse(0, "") is None
option = Hamlib.value_t()
option.i = 0 # FIXME should use a RIG_ANT_* constant but it isn't available in the bindings
assert rig.set_ant(Hamlib.RIG_VFO_CURR, option) is None
assert rig.set_ant(Hamlib.RIG_VFO_CURR, option, 0) is None
assert rig.set_bank(0, 0) is None
channel = Hamlib.channel()
channel = Hamlib.channel(0)
channel = Hamlib.channel(0, 0)
assert rig.set_channel(channel) is None
assert rig.set_conf("", "") is None
assert rig.set_ctcss_sql(0, 0) is None
assert rig.set_ctcss_tone(0, 0) is None
assert rig.set_dcs_code(0, 0) is None
assert rig.set_dcs_sql(0) is None
assert rig.set_dcs_sql(0, 0) is None
assert rig.set_ext_func(0, 0) is None
assert rig.set_ext_func(0, 0, 0) is None
level = 0
value = Hamlib.value_t()
assert rig.set_ext_level(level, value) is None
assert rig.set_ext_level(level, value, Hamlib.RIG_VFO_CURR) is None
value = Hamlib.value_t()
assert rig.set_ext_parm(0, value) is None
assert rig.set_freq(0, 0) is None
assert rig.set_func(0, 0, 0) is None
assert rig.set_level(0, 0, 0) is None
assert rig.set_mem(0, 0) is None
assert rig.set_mode(0) is None
assert rig.set_mode(0, 0) is None
assert rig.set_mode(0, 0, 0) is None
assert rig.set_parm(0, 0) is None
assert rig.set_powerstat(0) is None
assert rig.set_ptt(0, 0) is None
assert rig.set_rit(0, 0) is None
assert rig.set_rptr_offs(0, 0) is None
assert rig.set_rptr_shift(0, 0) is None
assert rig.set_split_freq(0, 0) is None
assert rig.set_split_freq_mode(0, 0) is None
assert rig.set_split_freq_mode(0, 0, 0) is None
assert rig.set_split_freq_mode(0, 0, 0, 0) is None
assert rig.set_split_mode(0) is None
assert rig.set_split_mode(0, 0) is None
assert rig.set_split_mode(0, 0, 0) is None
assert rig.set_split_vfo(0, 0) is None
assert rig.set_split_vfo(0, 0, 0) is None
assert rig.set_trn(0) is None # deprecated
assert rig.set_ts(0, 0) is None
assert rig.set_vfo(0) is None
assert rig.set_vfo_opt(0) is None
assert rig.set_xit(0, 0) is None
assert rig.token_lookup("") is None
assert rig.vfo_op(0, 0) is None
def test_object_creation(self):
"""Create all objects available"""
rig = Hamlib.Rig(RIG_MODEL)
assert rig is not None
assert isinstance(rig.caps, Hamlib.rig_caps)
assert isinstance(rig.state, Hamlib.rig_state)

Wyświetl plik

@ -0,0 +1,115 @@
#! /bin/env pytest
"""Tests of the Python bindings for Hamlib
Running this script directly will use the installed bindings.
For an in-tree run use "make check", or set PYTHONPATH to point to
the directories containing Hamlib.py and _Hamlib.so.
"""
from pytest import raises
import Hamlib
Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
ROT_MODEL = Hamlib.ROT_MODEL_DUMMY
class TestClass:
"""Container class for tests"""
TOK_EL_ROT_MAGICLEVEL = 1
TOK_EL_ROT_MAGICFUNC = 2
# TOK_EL_ROT_MAGICOP = 3 # handled by get_ext_level/set_ext_level
TOK_EP_ROT_MAGICPARM = 4
# TOK_EL_ROT_MAGICCOMBO = 5 # handled by get_ext_level/set_ext_level
TOK_EL_ROT_MAGICEXTFUNC = 6
def test_without_open(self):
"""Call all the methods that do not depend on open()"""
rot = Hamlib.Rot(ROT_MODEL)
assert rot is not None
assert rot.do_exception == 0
assert rot.error_status == Hamlib.RIG_OK
assert isinstance(rot.caps.model_name, str)
assert isinstance(rot.caps.mfg_name, str)
assert isinstance(rot.caps.version, str)
assert isinstance(rot.caps.copyright, str)
assert rot.set_conf("", "") is None
assert rot.get_conf("") == ""
assert rot.get_conf(0) == ""
conf = rot.get_conf("mcfg")
assert isinstance(conf, str)
assert rot.set_conf("mcfg", "foo") is None
conf = rot.get_conf("mcfg")
assert conf == "foo"
assert rot.token_lookup("") is None
def test_with_open(self):
"""Call all the methods that depend on open()"""
rot = Hamlib.Rot(ROT_MODEL)
assert rot is not None
assert rot.state.comm_state == 0
assert rot.open() is None
assert rot.state.comm_state == 1
info = rot.get_info()
assert isinstance(info, str)
assert rot.set_position(1.23, 4.56) is None
# When the Dummy rotator simulates movement, this test is too fast
# to see a changed position
assert rot.get_position() == [0.0, 0.0] # should be [1.23, 4.56]
assert rot.move(0, 0) is None
speed = 4
assert rot.move(Hamlib.ROT_MOVE_UP, speed) is None
assert rot.move(Hamlib.ROT_MOVE_LEFT, speed) is None
# When the Dummy rotator simulates movement, this test is too fast
# to see a changed position
assert rot.get_position() == [0.0, 0.0] # should be [-90.0, 90.0]
value = Hamlib.value_t()
value.i = 3
assert rot.set_level(Hamlib.ROT_LEVEL_SPEED, value) is None
assert rot.get_level(Hamlib.ROT_LEVEL_NONE) is None
assert rot.get_level(Hamlib.ROT_LEVEL_SPEED) == 3
with raises(AttributeError):
assert rot.status() is None
assert rot.stop() is None
assert rot.park() is None
assert rot.reset(Hamlib.ROT_RESET_ALL) is None
assert rot.set_ext_func(self.TOK_EL_ROT_MAGICEXTFUNC, 5) is None
assert rot.get_ext_func(self.TOK_EL_ROT_MAGICEXTFUNC) == 5
value.i = 6
assert rot.set_ext_level(self.TOK_EL_ROT_MAGICLEVEL, value) is None
assert rot.get_ext_level(self.TOK_EL_ROT_MAGICLEVEL) == 6
value.i = 7
assert rot.set_ext_parm(self.TOK_EP_ROT_MAGICPARM, value) is None
assert rot.get_ext_parm(self.TOK_EP_ROT_MAGICPARM) == 7
# Dummy rotator doesn't support functions
status = 0
assert rot.set_func(Hamlib.ROT_FUNC_NONE, status) is None
assert rot.get_func(Hamlib.ROT_FUNC_NONE) is None
# Dummy rotator doesn't support parameters
value.i = 5
assert rot.set_parm(Hamlib.ROT_PARM_NONE, value) is None
assert rot.get_parm(Hamlib.ROT_PARM_NONE) is None
assert rot.close() is None
assert rot.state.comm_state == 0
info = rot.get_info()
assert info is None
def test_object_creation(self):
"""Create all objects available"""
rot = Hamlib.Rig(ROT_MODEL)
assert rot is not None
assert isinstance(rot.caps, Hamlib.rig_caps)
assert isinstance(rot.state, Hamlib.rig_state)

Wyświetl plik

@ -0,0 +1,131 @@
#! /bin/env pytest
"""Tests of the Python bindings for Hamlib
Running this script directly will use the installed bindings.
For an in-tree run use "make check", or set PYTHONPATH to point to
the directories containing Hamlib.py and _Hamlib.so.
"""
from pytest import approx
import Hamlib
class TestClass:
"""Container class for tests"""
def test_startup(self):
"""Simple script to test the Hamlib.py module with Python3."""
assert isinstance(Hamlib.cvar.hamlib_version, str)
Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
model = Hamlib.RIG_MODEL_DUMMY
my_rig = Hamlib.Rig(model)
assert my_rig is not None
assert my_rig.set_conf("rig_pathname", "/dev/Rig") is None
assert my_rig.set_conf("retry", "5") is None
assert my_rig.open() is None
assert my_rig.get_conf("rig_pathname") == "/dev/Rig"
assert my_rig.get_conf("retry") == '5'
assert my_rig.error_status == Hamlib.RIG_OK
assert Hamlib.rigerror(my_rig.error_status) == "Command completed successfully\n"
assert my_rig.set_freq(Hamlib.RIG_VFO_B, 5700000000) is None
assert my_rig.set_vfo(Hamlib.RIG_VFO_B) is None
assert my_rig.get_freq() == 5700000000
assert my_rig.set_freq(Hamlib.RIG_VFO_A, 145550000) is None
(mode, width) = my_rig.get_mode(Hamlib.RIG_VFO_A)
assert Hamlib.rig_strrmode(mode) == 'FM'
assert width == 15000
assert my_rig.set_mode(Hamlib.RIG_MODE_CW) is None
(mode, width) = my_rig.get_mode()
assert Hamlib.rig_strrmode(mode) == 'CW'
assert width == 0
assert isinstance(my_rig.caps.copyright, str)
assert isinstance(my_rig.caps.model_name, str)
assert isinstance(my_rig.caps.mfg_name, str)
assert isinstance(my_rig.caps.version, str)
assert isinstance(Hamlib.rig_strstatus(my_rig.caps.status), str)
assert isinstance(my_rig.get_info(), str)
assert my_rig.set_level("VOXDELAY", 1) is None
assert my_rig.get_level_i("VOXDELAY") == 1
assert my_rig.set_level(Hamlib.RIG_LEVEL_VOXDELAY, 5) is None
assert my_rig.get_level_i(Hamlib.RIG_LEVEL_VOXDELAY) == 5
af = 12.34
assert my_rig.set_level("AF", af) is None
assert my_rig.error_status == Hamlib.RIG_OK
assert my_rig.get_level_f(Hamlib.RIG_LEVEL_AF) == approx(12.34)
assert my_rig.error_status == Hamlib.RIG_OK
assert my_rig.get_level_f(Hamlib.RIG_LEVEL_RFPOWER_METER)
assert my_rig.get_level_f(Hamlib.RIG_LEVEL_RFPOWER_METER_WATTS)
assert my_rig.get_level_i(Hamlib.RIG_LEVEL_STRENGTH)
chan = Hamlib.channel(Hamlib.RIG_VFO_B)
assert chan.vfo == Hamlib.RIG_VFO_B
assert my_rig.get_channel(chan, 1) is None
assert my_rig.error_status == Hamlib.RIG_OK
assert Hamlib.rig_strvfo(chan.vfo) == 'MainB'
assert chan.freq == 5700000000
assert my_rig.caps.attenuator == [10, 20, 30, 0, 0, 0, 0, 0]
# Can't seem to get get_vfo_info to work
#(freq, width, mode, split) = my_rig.get_vfo_info(Hamlib.RIG_VFO_A,freq,width,mode,split)
#print("Rig vfo_info:\t\tfreq=%s, mode=%s, width=%s, split=%s" % (freq, mode, width, split))
assert my_rig.send_morse(Hamlib.RIG_VFO_A, "73") is None
assert my_rig.close() is None
# Some static functions
err, lon1, lat1 = Hamlib.locator2longlat("IN98XC")
assert err == Hamlib.RIG_OK
assert lon1 == approx(-0.0417, abs=1.0e-04) # FIXME why need to override tolerance?
assert lat1 == approx(48.1042)
assert Hamlib.longlat2locator(lon1, lat1, 3) == [Hamlib.RIG_OK, 'IN98XC']
err, lon2, lat2 = Hamlib.locator2longlat("DM33DX")
assert err == Hamlib.RIG_OK
assert lon2 == approx(-113.7083)
assert lat2 == approx(33.9792)
assert Hamlib.longlat2locator(lon2, lat2, 3) == [Hamlib.RIG_OK, 'DM33DX']
err, dist, az = Hamlib.qrb(lon1, lat1, lon2, lat2)
assert err == Hamlib.RIG_OK
assert dist == approx(8765.814)
assert az == approx(309.0)
longpath = Hamlib.distance_long_path(dist)
assert longpath == approx(31266.186)
# dec2dms expects values from 180 to -180
# sw is 1 when deg is negative (west or south) as 0 cannot be signed
err, deg1, mins1, sec1, sw1 = Hamlib.dec2dms(lon1)
assert err == Hamlib.RIG_OK
assert deg1 == 0
assert mins1 == 2
assert sec1 == 29
assert sw1 == 1
err, deg2, mins2, sec2, sw2 = Hamlib.dec2dms(lat1)
assert err == Hamlib.RIG_OK
assert deg2 == 48
assert mins2 == 6
assert sec2 == 15
assert sw2 == 0
lon3 = Hamlib.dms2dec(deg1, mins1, sec1, sw1)
lat3 = Hamlib.dms2dec(deg2, mins2, sec2, sw2)
assert lon3 == approx(-0.0414, abs=1.0e-04) # FIXME why need to override tolerance?
assert lat3 == approx(48.1042)
assert my_rig.set_vfo_opt(0) is None

Wyświetl plik

@ -18,6 +18,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
%{
#include <hamlib/rig.h>
%}
%immutable rig_caps::model_name;
%immutable rig_caps::mfg_name;
%immutable rig_caps::version;
%immutable rig_caps::copyright;
%include <hamlib/riglist.h>
%include <hamlib/rig.h>
%inline %{
@ -453,7 +464,7 @@ typedef channel_t * const_channel_t_p;
METHOD1VGET(get_rit, shortfreq_t)
METHOD1VGET(get_xit, shortfreq_t)
METHOD1VGET(get_ts, shortfreq_t)
extern void get_ant(ant_t *ant_rx, ant_t *ant_tx, ant_t *ant_curr, value_t * OUTPUT, ant_t ant, vfo_t vfo = RIG_VFO_CURR);
extern void get_ant(ant_t *OUTPUT, ant_t *OUTPUT, ant_t *OUTPUT, value_t *OUTPUT, ant_t ant, vfo_t vfo = RIG_VFO_CURR);
extern void get_vfo_info (int *satmode, split_t *split, pbwidth_t *width, rmode_t *mode, freq_t *freq, vfo_t vfo = RIG_VFO_CURR);
METHOD1VGET(get_mem, int)
METHOD1GET(get_powerstat, powerstat_t)
@ -478,10 +489,6 @@ typedef channel_t * const_channel_t_p;
/* TODO: handle ext_level's */
}
void chan_clear(struct channel *chans, int nb_chans = 1) {
memset(chans, 0, sizeof(struct channel)*nb_chans);
}
void get_chan_all(struct channel *chans) {
self->error_status = rig_get_chan_all(self->rig, RIG_VFO_NONE, chans);
/* TODO: handle ext_level's */

Wyświetl plik

@ -18,6 +18,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
%{
#include <hamlib/rotator.h>
%}
%include macros.swg
%immutable rot_caps::model_name;
%immutable rot_caps::mfg_name;
%immutable rot_caps::version;
%immutable rot_caps::copyright;
%include <hamlib/rotator.h>
%include <hamlib/rotlist.h>
%inline %{
@ -78,6 +90,16 @@ typedef struct Rot {
ROTMETHOD0(open)
ROTMETHOD0(close)
ROTMETHOD2(set_ext_func, hamlib_token_t, int)
ROTMETHOD2(set_ext_level, hamlib_token_t, value_t)
ROTMETHOD2(set_ext_parm, hamlib_token_t, value_t)
ROTMETHOD2(set_func, setting_t, int)
ROTMETHOD2(set_level, setting_t, value_t)
ROTMETHOD2(set_parm, setting_t, value_t)
ROTMETHOD2(set_position, azimuth_t, elevation_t)
extern void get_position(azimuth_t *OUTPUT, elevation_t *OUTPUT);
ROTMETHOD0(stop)
@ -97,6 +119,15 @@ typedef struct Rot {
ROTMETHOD2(set_conf, hamlib_token_t, const_char_string)
ROT_GET_LONG(func)
ROT_GET_LONG(ext_func)
ROT_GET_VALUE_T(level)
ROT_GET_VALUE_T(ext_level)
ROT_GET_VALUE_T(parm)
ROT_GET_VALUE_T(ext_parm)
const char *get_conf(hamlib_token_t tok) {
static char s[128] = "";
self->error_status = rot_get_conf(self->rot, tok, s);

Wyświetl plik

@ -615,9 +615,32 @@ AS_IF([test x"${cf_with_python_binding}" = "xyes"],[
AM_CONDITIONAL([ENABLE_PYTHON], [test x"${cf_with_python_binding}" = "xyes"])
dnl Determine whether to install pytest.py or py3test.py to $(docdir)/examples
AM_PYTHON_CHECK_VERSION([${PYTHON}], [3.0], [pyver_3="yes"], [pyver_3="no"])
AM_CONDITIONAL([PYVER_3], [test x"${pyver_3}" = x"yes"])
AC_ARG_ENABLE([pytest],
[AS_HELP_STRING([--enable-pytest],
[execute Python tests @<:@default=check@:>@])
],
[enable_pytest=check]
)
AS_IF([test "x$enable_pytest" != "xno"],
[AC_PATH_PROG([PYTEST], [pytest])]
)
AS_IF([test "x$PYTEST" = "x"],
[have_pytest=no],
[have_pytest=yes]
)
AS_IF([test "x$enable_pytest" = "xyes"],
[AS_IF([test "x$have_pytest" = "xno"],
[AC_MSG_ERROR([pytest requested but not found])]
)]
)
# "check" is replaced by the rsult ("yes" or "no")
enable_pytest=$have_pytest
AC_SUBST([enable_pytest])
# Tcl binding
AC_MSG_CHECKING([Whether to build Tcl bindings])
@ -980,5 +1003,6 @@ echo \
Enable USB backends ${cf_with_libusb}
Enable shared libs ${enable_shared}
Enable static libs ${enable_static}
Enable Python tests ${enable_pytest}
-----------------------------------------------------------------------"