summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-09-07 21:28:59 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-09-07 21:28:59 +0200
commit26cdc783c935a2a9b41af0083dcafe401589d41e (patch)
tree9fb5de793445c46829d36e6e78235cc22edb17d0
parent69a0fdd630b13d8864d7dfe494205139d5ecb079 (diff)
downloadcssh-26cdc783c935a2a9b41af0083dcafe401589d41e.tar.gz
cssh-26cdc783c935a2a9b41af0083dcafe401589d41e.tar.bz2
a first playing around with ANSI on bash
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/cssh.c2
-rw-r--r--src/progressbar.c4
-rw-r--r--src/progressbar.h2
-rw-r--r--tests/CMakeLists.txt6
-rw-r--r--tests/progressbartest.c32
6 files changed, 43 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 807c838..4f62ffe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,7 @@ set( CSSH_VERSION 0.0.1 )
set(CMAKE_C_FLAGS "-std=c99 -Wall -pedantic -Wfatal-errors -Werror -fPIC -O0 -Wno-unused-but-set-variable -g -D_XOPEN_SOURCE=700")
add_subdirectory(src)
+add_subdirectory(tests)
add_custom_target(distclean
COMMAND make clean
diff --git a/src/cssh.c b/src/cssh.c
index 2b3663a..4a58c03 100644
--- a/src/cssh.c
+++ b/src/cssh.c
@@ -1355,7 +1355,7 @@ int main( int argc, char *argv[] )
scp_data[i].fd = 0;
free( scp_data[i].filename );
scp_data[i].filename = NULL;
- remvove_progressbar_from_pool( &progressbars, &scp_data[i].progressbar );
+ remove_progressbar_from_pool( &progressbars, &scp_data[i].progressbar );
free_progressbar( &scp_data[i].progressbar );
}
break;
diff --git a/src/progressbar.c b/src/progressbar.c
index f8a4121..3d07e4e 100644
--- a/src/progressbar.c
+++ b/src/progressbar.c
@@ -32,7 +32,7 @@ void free_progressbar( cssh_progressbar_t *progressbar )
void set_value_of_progressbar( cssh_progressbar_t *progressbar, uint64_t value )
{
- fprintf( stderr, "%s %"PRIu64"\n", progressbar->label, value );
+ fprintf( stderr, "%s %"PRIu64" \n", progressbar->label, value );
}
int create_progressbar_pool( cssh_progressbar_pool_t *pool, size_t initial_size )
@@ -68,7 +68,7 @@ int append_progressbar_to_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_
return 0;
}
-int remvove_progressbar_from_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_t *progressbar )
+int remove_progressbar_from_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_t *progressbar )
{
if( pool->N == 0 ) {
return -1;
diff --git a/src/progressbar.h b/src/progressbar.h
index 70e93f8..71eaed1 100644
--- a/src/progressbar.h
+++ b/src/progressbar.h
@@ -32,6 +32,6 @@ void free_progressbar_pool( cssh_progressbar_pool_t *pool );
int append_progressbar_to_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_t *progressbar );
-int remvove_progressbar_from_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_t *progressbar );
+int remove_progressbar_from_pool( cssh_progressbar_pool_t *pool, cssh_progressbar_t *progressbar );
#endif
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..f3becb6
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories(../src)
+
+add_executable(progressbartest progressbartest.c ../src/progressbar.c ../src/port.c)
+
+target_link_libraries(progressbartest ncurses)
+
diff --git a/tests/progressbartest.c b/tests/progressbartest.c
new file mode 100644
index 0000000..8e6e0bf
--- /dev/null
+++ b/tests/progressbartest.c
@@ -0,0 +1,32 @@
+#include "progressbar.h"
+#include "port.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main( void )
+{
+ cssh_progressbar_t p1;
+ cssh_progressbar_t p2;
+ cssh_progressbar_pool_t pool;
+
+ create_progressbar_pool( &pool, 2 );
+ create_progressbar( &p1, 0, 100, 100, "[Running on host %s]:", "host1" );
+ create_progressbar( &p2, 0, 100, 100, "[Running on host %s]:", "host2" );
+ append_progressbar_to_pool( &pool, &p1 );
+ append_progressbar_to_pool( &pool, &p2 );
+ for( unsigned int i = 0; i < 100; i++ ) {
+ set_value_of_progressbar( &p1, i );
+ set_value_of_progressbar( &p2, 100 - i );
+ cssh_msleep( 100 );
+ printf( "\33[3F\n" );
+ }
+
+ free_progressbar( &p1 );
+ free_progressbar( &p2 );
+ remove_progressbar_from_pool( &pool, &p2 );
+ remove_progressbar_from_pool( &pool, &p1 );
+ free_progressbar_pool( &pool );
+
+ exit( EXIT_SUCCESS );
+}